Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


546


Setting a watch is more complicated than using the Locals window or setting a breakpoint:


  1. In the Watches window, click on the Watch tab.

  2. The Add Watch dialog box (see Figure 14.22) appears.


FIGURE 14.22
The Add Watch dialog box includes some powerful options.


  1. Enter the name of the variable or any other expression in the Expression text box.


The Add Watch dialog box includes some important options. In addition to the name of a variable
or expression (an expression might be something like sSQL = ““), there are options for specifying
the module and procedure within the module to watch. In Figure 14.23, the Add Watch dialog
box is set up to watch the sSQL variable in all procedures in all modules.

At the bottom of the Add Watch dialog box are the following options:

l (^) Watch Expression: The variable’s value will dynamically change in the Watch window.
You must use an explicit breakpoint or Stop statement in order to observe the value of
the watched variable.
l Break When Value Is True: This option asserts a break whenever the value of the
watched variable or expression becomes True. If you set the expression to sSQL = ““, a
breakpoint occurs whenever the value of the sSQL variable changes to an empty string.
l (^) Break When Value Changes: This directive causes Access to halt execution whenever the
value of the variable or expression changes. Obviously, this setting can generate a lot of
breakpoints!
Caution
Use watches wisely. You don’t want to be breaking into program execution too frequently or you’ll never get
through the code. On the other hand, you don’t want to overlook some important change in the value of a
variable because you didn’t set a watch appropriately.

Free download pdf