Create a macro

Create a macro

  1. In the Database window, click Macros under Objects.

  2. Click the New button on the Database window toolbar.

  3. In the Action column, click in the first cell and then click the arrow to display the action list.

  4. Click the action you want to use.

  5. Type a comment for the action. Comments are optional, but make your macro easier to understand and maintain.

  6. In the lower part of the window, specify arguments for the action, if any are required. For tips on setting action arguments, click .

  7. To add more actions to the macro, move to another action row, and repeat steps 3 through 6. Microsoft Access carries out the actions in the order you list them.

Tip   To quickly create a macro that carries out an action on a specific database object, drag the object from the Database window to an action row in the Macro window. For example, you can create a macro that opens a form by dragging the form to an action row. To do this, click Tile Vertically on the Windows menu to position the Macro window and Database window so that they're side by side on your screen; in the Database window under Objects, click the object type you want, click the object, and then drag it to an action row. Dragging a macro or stored procedure adds an action that runs the macro or procedure, while dragging other database objects adds an action that opens the object.