Saturday, November 13, 2021

Test a macro by using single step mode

By single stepping through a macro, you can observe the flow of the macro and the results of each action, and isolate any action that causes an error or produces unwanted results.

  1. Right-click the macro in the Navigation Pane, and then click Design View.

  2. On the Design tab, in the Tools group, click Single Step.

  3. Click Run. If the macro is a new or edited macro, you will be prompted to save the macro before you can run it.

    The Macro Single Step dialog box appears. This dialog box displays information about the macro and the macro action, as well as the error number. A zero in the Error Number box means no error has occurred.

    Macro Single Step dialog box

  4. Do one of the following:

    • To carry out the action shown in the Macro Single Step dialog box, click Step.

    • To stop the macro and close the dialog box, click Stop All Macros.

    • To turn off single stepping and run the remainder of the macro, click Continue.

Remarks

  • To begin single stepping while a macro is running, press CTRL+BREAK.

  • To begin single stepping at a specific point in your macro, you can add the SingleStep macro action to your macro at the point where you want single stepping to begin. Use the following procedure to add the SingleStep macro action to your macro:

    1. In the Action Catalog on the right side of the macro design window, search for SingleStep. If the Action Catalog is not displayed then turn it on from the Design tab, in the Show/Hide group, click Action Catalog.

    2. Drag the SingleStep macro action from the Action Catalog onto the design window and drop the action above or below where you want the single stepping to begin. This action has no action arguments.

    3. Save the macro by clicking Save on the Quick Access Toolbar.

      Assuming that single stepping is turned off when you click Run, execution will proceed normally up to the point where you inserted the SingleStep macro action, and then the macro will begin single stepping. You can add multiple SingleStep actions to a macro. Clicking Continue in the Macro Single Step dialog box will switch single stepping off until the next SingleStep action is encountered.

      If single stepping is on when the macro ends, it will remain on. If you run another macro, Access will display the Macro Single Step dialog box again. To turn off single stepping, click Continue in the Macro Single Step dialog box or, on the Design tab, in the Tools group, click Single Step so that it is not highlighted.

No comments:

Post a Comment