We continue our discuss of Access 2010 Macros this week by looking at the AutoExec macro. An AutoExec macro is a macro that automatically executes when you open a database. For instance, you may wish to display a particular form when the database is opened or perhaps display an informational message to your user. One of my favorite uses for this macro is to hide the Navigation Bar and then display a Switchboard form.
To create an AutoExec macro, create a macro as you would any other but name it: Autoexec.
Note that an AutoExec macro will run after the Startup Options have taken effect; therefore, you should avoid any actions in your AutoExec macro that will change the effect of the Startup Option settings.
The AutoExec macro executes when a database is opened
To Create an AutoExec Macro
- Click the Create tab on the Ribbon.
- Click the Macro button on the Macros & Code group on the Ribbon.
- Click the drop-down arrow on the Add New Action drop-down list and choose the action from the list that you want the macro to carry out
Double-click the action you wish to use in the Action Catalog (click the plus or minus signs to expand or collapse the Actions groups)
Drag an action from the Action Catalog to the Macro window.
- In the lower part of the window, enter any arguments for the action, if required.
- To add more actions to the macro, move to the next blank Add New Action drop-down list and repeat steps 3-5 (Access executes the macro actions in the order that they are listed in the action column).
- Click the Save button and then name your macro AutoExec. Make sure that any actions in your AutoExec macro do not change the effect of the startup option settings.
Applies to Microsoft Access 2010