Part II: Programming Microsoft Access
548
FIGURE 14.24
A conditional watch halts execution when the expression CustomerID=99 is true.
Tip
The Watches window is more than a static display. If needed, you can click on an item in the Expression col-
umn and change a watched expression. For example, let’s say you set up a watch containing an expression as
TotalSale > 100 and directed the watch to assert a breakpoint as soon as this expression becomes true. You
may find that the breakpoint occurs much too often for your testing purposes. Instead of deleting the watch
expression and starting over, you can easily modify the expression, replacing 100 with 200 or any other value
you’d like to try.
You can have as many watches as you want, but, as with all other debugging tools, the watches are
removed when you exit Access.
Tip
If, while working with conditional watches, you find a particular expression useful, you may want to write it
down for future use.
Using the Call Stack window
The last debugging tool I’ll examine is a bit more difficult to understand because it involves “multi-
ple dimensions” of execution. In many Access applications, you’ll have procedures that call other
procedures that call still other procedures. To my knowledge, there is no practical limit on the
number of procedures that can be sequentially called in a VBA project. This means you may have a
“tree” of procedures many levels deep, one level of which is causing problems in your application.
This situation is particularly true in the case of an application that has been modified many times,
or when little thought was given to optimizing how the code in the application is used.
Even so, some very carefully designed applications end up with deeply nested code, making it dif-
ficult to understand how all the code ties together.
Imagine a function that performs a common operation (such as calculating shipping costs) in an
application. As a general rule, rather than include this function in every module in the application,