Today, we continue our discussion of Access macros and take a look at macro groups. If you find yourself creating a large number of macros, creating macro groups can help you manage your macros more easily. A macro group is a collection of related submacros all stored together in a single macro object. If you have used macro groups in previous versions of Access, you may be trying to figure out how to do the same in Access 2010 – as the process has completely changed (it personally took me awhile to figure it out!).
In the illustration below, the macro group, named mcrOpenForms, is made up of three related macros: OpenRegistration, OpenStudents and OpenClasses. The name next to the word Submacro identifies each separate group of macro actions and specifies the beginning of the macro. When the group is expanded, the words End Group mark the end of the macro in that group. These three macros were included in this group because each macro carries out the OpenForm action.
You can run a macro in a macro group in an event by typing the macro group name followed by a period and then the macro name. In the preceding example, to refer to the OpenStudents macro in the mcrOpenForms macro group, you would type:
Note that the Submacro action is different than the Group action. Group actions cannot be called or executed – they mainly serve to increase readability by storing program flow in named, collapsible blocks.
To Create a Macro Group
- Create a blank new Macro.
- Click the Add New Action drop-down arrow and choose Submacro from the list.
Expand the Program Flow category in the Action Catalog window and double-click Submacro.
- Click in the Submacro box and type in a name for the group. This is how you identify each individual macro.
- Add the actions to the group you want the macro to carry out.
- To add another macro, click anywhere outside of the group and repeat steps 2-4.
- When finished, click the Save button and provide a descriptive name for the Macro Group.
Note: You cannot run a macro group (a macro containing submacros) directly from the macro window. Submacros can only be called by a RunMacro or OnError macro action.