You can use data macros to tables to do tasks like add, update or delete data or validate the accuracy of data. Data macros can be programmed to run immediately before or after you add, update or delete data in a table.
-
In the Navigation Pane, double-click the table to which you want to add the data macro.
-
Click Table and click 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.
-
Add the macro actions.
-
Save and close the macro.
About parameters
Parameters are used in expressions to pass values and object references into a named data macro.
-
At the top of the macro, click Create Parameter.
-
In the Name box, type a unique name for the parameter.
-
Optionally, add a description in the Description box as a tip to identify the purpose of the parameter.
Edit data macros
Use the Ribbon commands to create or modify data macros.
Edit a data macro
-
Open the table with the data macro that you want to edit.
-
Click the Table tab > click 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 opens the Macro Builder, and you can begin editing it.
Rename or delete a macro
-
Open the table with the data macro that you want to rename or delete.
-
Click Table tab > Named Macro > Rename/Delete Macro.
-
In the Data Macro Manager dialog box, click Rename or Delete next to the data macro that you want to modify.
-
To rename, enter the new name and press ENTER on your keyboard.
For more, see creating a macro that runs when you open a database.