New to Access 2010 are data macros. They are very powerful, and they take Access macros to a whole new level.
A data macro is a macro that
executes in response to data changing within a table. The following are
the events that you can respond to:
After data is inserted
After data is updated
After data is deleted
Before data is deleted
Before data is changed
Respond to Events
Here’s how it works:
1. | Open the table to which you want to add the data macros in Design view.
|
2. | Click
the Create Data Macros drop-down in the Field, Record & Table
Events drop-down on the Table Tools Design tab of the Ribbon. The
drop-down appears as in Figure 1.
|
3. | Select the event you wish to respond to. For the example I have selected After Insert (see Figure 2).
|
4. | Open the Action drop-down and select the desired action. In Figure 3,
I have selected LookUpRecord. Access prompts for the table in which to
look up the record, the condition under which to perform the action, and
the action to perform. The completed event appears in Figure 4.
It looks up a record in the Users table where the Order ID in the
Orders table matches the Order ID of the current record in the Order
Details table. It then increments the value of the field
NumberOfDetailItems in the Orders table by 1.
|