Access for Office 365 Access 2019 Access 2016 Access 2013
You can apply data macros to tables to do tasks like add, update or delete data or validate the accuracy of data. Data macros can be embedded to run immediately before or after you add, update or delete data in a table.
- In the Navigation Pane, double-click your relevant table in which you want to add the data macro.
- Select Table and choose the event where you want to add the macro. For example, for a data macro that runs after you delete a record from the table, click After Delete.
- Insert the macro actions.
- Save and exit the macro.
Parameters are used in expressions to pass values and object references into a named data macro.
- At the top of the macro, select Create Parameter.
- In the Name box, write a distinct name for the parameter.
- Optionally, input a description in the Description box as a tip to ascertain the purpose of the parameter.
Edit data macros
Use the Ribbon commands to make or update data macros.
Edit a data macro
- Access the table with the data macro that you want to edit.
- Pick the Table tab > choose the event for the macro that you want to edit.
Note: If an event does not have a macro associated with it, its icon is not highlighted on the menu.
- Access launches the Macro Builder, and you can begin editing it.
Rename or delete a macro
- Access the table with the data macro that you want to rename or delete.
- Press Table tab > Named Macro > Rename/Delete Macro.
- In the Data Macro Manager dialogue box, select Rename or Delete beside the data macro that you want to modify.
- To rename, state the new name and press ENTER on your keyboard.
For more, see creating a macro that runs when you open a database.