Microsoft Office Tutorials and References
In Depth Information
Attaching Macros to Tables
3. Choose an event from the list of triggering events.
The most common choices are After Insert and After Update,
for checking information that has been entered. Access creates a macro
that’s attached to the table; this macro is named table name : event
(Orders : After Update, for example). When you make your choice,
the Macro Builder appears.
4. Add actions to the macro based on what you want Access to do when
the triggering event occurs.
In the Macro Builder, when you click the Add New Action check box or
look at the Action Catalog, the available actions aren’t the same as those
that are available when you’re making regular actions. The actions that
you can use center on editing a record in the table.
Figure 2-2 shows a data macro that sets the Sales Tax Rate Applied
• TheEditRecord action tells Access to make and save changes to
the current record.
• TheSetField action sets the value of a field (specified with the
Name argument) in that record to the value in the Value argument.
5. Close the macro tab to return to your table in Design view.
6. Close the table in Design view, or switch to Datasheet view.
When you save changes to the table design, Access saves changes to the
data macros for the table too.
Now when you edit records in the table, Access runs the data macro after
each update. If Access makes a change, a red box appears briefly around the
field that it’s changing.