The Submacro statement in Access defines a separate macro in the Macro Designer window.
The Submacro action has only one required argument.
A string that appears as the name of the macro.
You can use the Submacro statement to define separate sets of actions. You can run the actions defined in submacros from another macro using the RunMacro action. In the Macro Name argument of the RunMacro action, use the following syntax to run the submacro:
<macro name>.<submacro name>
You can also use the Submacro statement to define an error handling set of actions within a macro.
The following macro demonstrates the use of the Submacro statement along with a OnError macro action. In this example, the OnError action specifies that Access run a custom error handling submacro named ErrorHandler when an error occurs. If an error occurs in any of the actions that follow, Access jumps to the ErrorHandler submacro. The ErrorHandler submacro displays a message box that refers to the MacroError object to display information about the error.
Here is a screenshot of the Access macro designer (Access version 2010 and higher) with the previous example. In this case, the expression in the SetLocalVar action triggers an error because it is trying to divide a number by zero. Access moves down to the submacro named ErrorHandler and displays the error information in a message box.