How to Create a Macro in Access

To create a macro in Microsoft Access 2013 or 2016:

  1. Click Macro from the CREATE tab
  2. Add actions by selecting an action from the combo box
  3. Customise the actions if required
  4. Repeat steps 2 and 3 for each action you want to add
  5. Save the macro

The following screenshots show an example of the above steps.

The Macro Button

Click Macro from the CREATE tab.

Screenshot of the Macro button on the Ribbon in MS Access 2013.
The “Macro” button on the Ribbon.

The Combo Box

Select an action from the combo box.

Screenshot of combo box while creating a macro in Access 2013.
A combo box displaying a list of actions when creating a macro.

 

Customise the Action

Customise the actions if required.

Screenshot of the OpenForm dialog in Access 2013.
The above dialog box is for configuring the OpenForm action. This allows you to add any parameters you require for the action.

Repeat if Required

Repeat steps 2 and 3 for each action you want to add.

Repeating step 2 (selecting another action from the combo box) adds the action here, where again, you can configure as required.

Screenshot of creating a second action for a macro in Access 2013.
Adding another action – this time using the GoToRecord action. This example is setting the macro to open a new record whenever it is run.

Save the macro

Screenshot of saving a macro in MS Access 2013.
Saving the macro as “AutoExec”. By using this name, the macro will be run every time the user opens the database.

Testing your Macro

You should always test your macro to make sure it does what you expect it to do.

Using the above example, you could close the database then open it again to make sure that the macro runs when the database is opened.

You should check that the database does in fact, open the form (as specified in the first action) and open a new record (as specified in the second action).

Macros can be as complex as you like, so try to think about all scenarios that need to be tested.

Creating a Button to Run a Macro

The above macro runs every time the database is opened but you probably won’t want all your macros running every time the database is opened.

You can create a button to run a macro instead. Here’s how to add a macro button to a form. The user can run the macro by clicking the button.