Run Time, Design Time, and Break Mode

The VBA IDE can be in any one of three modes: run mode , break mode, or design mode. When the IDE is in design mode, we can write code.

Run mode occurs when a procedure is running. To run (or execute) a procedure, just place the cursor anywhere within the procedure code and hit the F5 key (or select Run from the Run menu). If for some reason a running procedure seems to be hanging, we can usually stop the procedure by hitting Ctrl+Break (hold down the Control key and hit the Break key).

Break mode is entered when a running procedure stops because of either an error in the code or a deliberate act on our part (described a bit later). In particular, if an error occurs, Access will stop execution and display an error dialog box, an example of which is shown in Figure 9.2.

An error message

Figure 9-2. An error message

Error dialog boxes offer a few options: end the procedure, get help (such as it may be) with the problem, or enter break mode to debug the code. In the latter case, Access will stop execution of the procedure at the offending code and highlight that code in yellow. We will discuss the process of debugging code a bit later.

Aside from encountering an error, there are several ways we can deliberately enter break mode for debugging purposes:

  • Hit the Ctrl+Break key and choose Debug from the resulting dialog box.

  • Include a Stop statement in the code, which ...

Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.