8.8. Investigating Variables
Now that you can see your code and the line that might be causing the problem, it's time to investigate. The error message— Object variable or With block variable not set —is a clue, but it doesn't tell you exactly what the problem is. The first step is to check the current values of the variables near the line that caused the error. Remember, your code is suspended, so all your variables are intact and able to report their values.
The quickest and easiest way to determine the value of a variable is to hover your mouse pointer over the variable name in the code window when your code is suspended. If the variable is part of a longer phrase, though, hovering may not work. For example, the variable Me.BusinessKey is simple enough to be hoverable (see Figure 8-6).
Figure 8.5. Figure 8-5
Figure 8.6. Figure 8-6
Because BusinessKey has a reasonable value, it doesn't seem to be the problem. To check variables or objects that are part of a more complex statement, highlight the portion you are interested before you hover over it. In this example, just hovering over the object name db doesn't display anything, but after selecting db, hovering provides a value, as shown in Figure 8-7.
Figure 8.7. Figure 8-7
By checking the value of db, you can see that it ...