To add a macro to a form in Access 2013 or 2016:
- Create a macro
- Now, open the form in Design view
- Click the Button icon in the Ribbon (from the DESIGN tab)
- In the Form Detail area, click and drag the cursor so that it forms a square or rectangle (i.e. shape of a button). The Command Button Wizard will pop up. Select Miscellaneous > Run Macro and click Next
- Select the name of the macro you want to run and click Next
- Choose whether to display text or an image on the button and click Next
- Give the button a name and click Finish
Below are screenshots for the above steps.
Create a Macro
Here’s an example of a macro that runs a query. If you don’t know how to create macros, see how to create a macro in Access.
Open the Form
Now, open the form in Design view.
Click the Button Icon
Click the Button icon in the Ribbon (from the DESIGN tab):
Add the Button to the Form
In the Form Detail area, click and drag the cursor so that it forms a square or rectangle (i.e. shape of a button). The Command Button Wizard will pop up. Select Miscellaneous > Run Macro and click Next:
Select the Macro
Select the name of the macro you want to run and click Next.
Text or Image Button?
Choose whether to display text or an image on the button and click Next.
Name the Button
Give the button a name and click Finish.
The user can now run the macro by clicking on the button.