O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.7. Debugging VBA

Programming in VBA isn't easy. No matter how skilled you are there are times when you need help figuring out what the code is actually doing. Fortunately, VBA provides a rich and powerful debugging environment. You can stop the code at various times and for various reasons, view values of variables (and even change them), and step through your code line-by-line until you understand what's going on.

8.7.1. Responding to Errors

The main reason you'll need to debug your code is because Access has displayed an error message. Hopefully you've put error handling in your code, which can make this activity easier. This topic is covered extensively in Chapter 9.

Let's say you've coded a cool copy routine like the one shown earlier in this chapter. However, when you try it, Access displays an error. If you don't have error handing, a message box will be displayed, as shown in Figure 8-2.

If you do have error handling, good job! Your error handling message box will be displayed, as shown in Figure 8-3.

When Access displays your handled error message box, your code execution is suspended. To get the opportunity to debug your code, press Ctrl-Break on your keyboard to interrupt code execution and display the dialog box shown in Figure 8-4.

Figure 8.2. Figure 8-2
Figure 8.3. Figure 8-3
Figure 8.4. Figure 8-4

Whichever way you get there, you can finally click the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required