Although Access doesn't offer very sophisticated tools for testing and debugging macros, it does give you a method for stepping through each line of a macro:
Open the macro in Design view.
Click Single Step on the toolbar or select Run | Single Step.
To execute the macro, click Run. Access executes the first line of the macro, and the Macro Single Step dialog box appears, showing the macro name, condition, action name, and arguments (see Figure 13.18). In the figure, the macro name is mcrPersonalInfo, the condition evaluates to True, and the action name is MsgBox. The MsgBox arguments are You Are Over a Quarter Century Old, Yes, and Information.
To continue stepping through the macro, click the Step button on the Macro Single Step dialog box. If you want to halt the execution of the macro without proceeding, click the Halt button. To continue normal execution of the macro without stepping, click the Continue button.
It's easiest to learn about stepping through a macro by experiencing it firsthand. Here's what you do:
Open (in Design view) the mcrPersonalInfo macro that you created earlier in this hour.
Click the Single Step button on the Macro Design toolbar. Run the frmPersonalInfo form, also created earlier in this hour.
Select a gender and type in a birth date.
Click the Check Gender command button; this should invoke the Macro Single Step dialog box.
Step through the macro one step at a time. View the macro name, condition, action name, and arguments for each step.
Change the gender and run the macro again. Carefully observe how this affects the macro's execution.
Click the Check Birth Date command button. Step through the macro one step at a time, viewing whether the condition evaluates to True or False.
After the macro ends, try entering a different value for the birth date. Step through the macro again and carefully observe whether the condition evaluates to True or False for each step.
As you can see, although Microsoft supplies some tools to help you debug a macro, you will probably agree that they're quite limited. That's one reason most experienced developers prefer to develop applications by using VBA code.
The Single Step button on the Macro Design toolbar toggles. When you activate Step mode, you activate it for all macros in the current database and all other databases until you either turn the toggle off or exit Access. This can be quite surprising if you don't expect it. You might have invoked Step mode in another database quite a bit earlier in the day, only to remember that you forgot to click the toggle button when you run another macro and that macro unexpectedly goes into Step mode.