Access 2016: Create a Macro

Automate common tasks by creating a macro.

A macro is a set of actions that can be run automatically, and on demand. Macros can be used to automate repetitive tasks, which can save time and effort for the user.

Macros are usually configured to run whenever a particular event occurs. You specify what that event is when you create the macro.

You can create macros for almost any task, or set of tasks. The great thing about macros is that they can run many tasks, one after the other, all at the click of a button. They can even be configured to run automatically as soon as the database is opened.

Create a Simple Macro

We'll now create a macro that opens a form automatically whenever the database is opened. We'll open the form that we created previously. This form enables the user to enter new albums into the database.

  1. Screenshot of the Macro button highlighted.

    Create a new Macro

    Click the Macro button from the Create tab on the Ribbon.

    This creates a blank macro, ready to be set up.

  2. Screenshot of the combo box.

    Select an Action

    Select OpenForm from the combo box.

    You can also do this by double-clicking OpenForm from the Action Catalog at the right of the screen.

  3. Screenshot of the macro.

    Configure the Action

    Select Albums from the Form Name combo box.

    Set View to Form and Window Mode to Normal.

  4. Screenshot of the macro.

    Select another Action

    Select GoToRecord from the combo box.

    You can also do this by double-clicking GoToRecord from the Action Catalog at the right of the screen.

  5. Screenshot of the macro.

    Configure the Action

    Select New from the Record combo box.

  6. Screenshot of the macro. Screenshot of the macro.

    Save the Macro

    Right-click on the macro's tab and select Save from the contextual menu.

    Name the macro AutoExec and click OK.

    Important: Be sure to name this macro AutoExec. This is a special name that makes the macro run whenever the database is opened.

The macro has now been created. Now let's test the macro to see if it works.

Run the Macro

The only way to test the macro is to run it.

One way to run it is to double-click on it in the left navigation pane.

But to test it properly, we need to make sure that it will run when the database is opened. Therefore, we'll need to close the database and open it.

  1. Screenshot of Access with the File tab highlighted. Screenshot of the File menu.

    Close the Database

    Click the File tab on the Ribbon.

    Then click Close from the menu.

  2. Screenshot of the Access File menu.

    Open the Database

    Click the File tab on the Ribbon again.

    Then click Open from the menu.

    Then click the database to open it. In our case, click Music.

  3. Screenshot of Access with the form open after the macro has run.

    The Form

    The database opens and the form automatically appears.

    Not only that, but the form is open at a blank record, ready for a new record to be entered.

    Our macro was successful!