To find out what events you can use for the various objects:
- Pick Microsoft Access Help from the Help menu.
- While in the Index tab, type
Event in the "1. Type keywords" field, then press Enter.
- Choose a topic field from the "3. Choose a topic field", and then press Enter.
You will then see something similar to this figure, which lists the various events and the objects they apply to.
You can use three types of table events in web apps, each attached to an event on the table.
- After Insert,
- After Update, and
- After Delete
As the names for each event imply, they fire when you add a new record, modify an existing record, or delete a record, respectively.
If you want the same data macro to be executed from more than one table event, consider using a standalone data macro and calling it in each table event.
Though the table events are labeled "After", you still can cancel such events by raising an error within the table event which will then prevent the
action, be it inserting, updating or deleting, from completing. Generally speaking, a data macro is usually executed when a UI macro invokes the data macro via a RunDataMacro macro action or via one of the table events.
In a standalone data macro, it is necessary to first establish the context in order to perform data modifications.
What this means is that you must specify the table on which the data macro will make changes.
On table events, the context is usually already established and you can have your macro act directly on the current record.
In the case of an update or delete event, you also have access to the old virtual table, which contains the original data from the affected row of the table.