Sometimes you have no clue where the problem lies, so you don't know where to set the breakpoint. However, you may want to suspend your code and investigate whenever a certain variable is set to a certain value. To do this you can use a watch value.
A watch value allows you to suspend execution of your code whenever a variable or object (or expression using a variable or object) changes or has a certain value. This is very powerful in complex code scenarios where you are having trouble finding where your logic is going wrong. You create watch values using the Add Watch window (see Figure 8-9), which you can request using Debug..Add Watch or by right-clicking in the Watches window.
Note that you can watch a single field, or you can type in an expression that uses multiple variables or values. Also, you can widen the context; it defaults to the procedure you are in, but you can widen it to include all procedures. Finally, you can choose to merely watch the expression, to break (suspend your code execution) when the expression becomes true (for example, BusinessKey = 949), or to break every time your expression changes. After you add your watch, it will appear in the Watches window, as shown in Figure 8-10.
Break When Value Is True
*' Efjeak i%eri Value Changes;
When the break condition you specified occurs, your code is displayed in the window. However, now you have an additional window, the Watches window. You can add more watch expressions here too, and if you specify an object to watch (like a form, report, recordset, et cetera), you can even drill down to all of its properties using the plus sign (+) next to the object name.
Was this article helpful?