your image

Access 2016: Create a Macro

quackit
Related Topic
:- MS Access Excel VBA and macro’s

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. 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. 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. Configure the Action

    Select Albums from the Form Name combo box.

    Set View to Form and Window Mode to Normal.

  4. 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. Configure the Action

    Select New from the Record combo box.

  6. 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. Close the Database

    Click the File tab on the Ribbon.

    Then click Close from the menu.

  2. 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. 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

 

Comments