Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


528


A common bug in applications with poor control over variables occurs when a variable is used out
of context. It’s easy to mistake one variable (like LastName) for another variable (like LName),
particularly in large or complex applications. Bugs like this can be extremely difficult to resolve
because the code may run fine even though data is being mishandled. By using the Option
Explicit directive in every code module, you can be sure every variable is properly declared,
making it much less likely you’ll use LastName as a variable in one procedure, and LName in
another procedure.

The Require Variable Declaration setting affects only new code modules added to the application.
You’ll have to manually add this directive to the top of existing module before variable declaration
is enforced throughout the application.

Auto List Members
This option pops up a list box containing the members of an object’s object hierarchy in the code
window. In Figure 14.3, you can see the list of Application objects that appeared as soon as I
typed the period following Application in the VBA statement. Use the up and down arrow keys
to locate an item in this list and select it or continue typing in the object reference.

FIGURE 14.3

Auto List Members makes it easy to recall the members of an object’s hierarchy.


Auto Quick Info
When you select Auto Quick Info, Access pops up syntax help (see Figure 14.4) when you enter
the name of a procedure (function, subroutine, or method) followed by a period, space, or opening
parenthesis. The procedure can be a built-in function or subroutine or one that you’ve written
yourself in Access VBA. This option helps you learn and understand the proper syntax of each
command and method.
Free download pdf