Part II: Programming Microsoft Access
558
FIGURE 15.4
The If block conditionally executes macro actions.
Condition Additional branching logic
If block Action to take when condition is true
Data blocks may also be nested. You could, for example, set up a ForEachRecord, and then run
the CreateRecord block, adding records to another table with data contained in the records
returned by the ForEachRecord.
The data-blocks macro actions are
l CreateRecord: The CreateRecord action provides a way to add a record to the cur-
rent table (which is rarely done) or to another table (which is more typical). An example
of using CreateRecord is building a log of all changes to the Products table. The
CreateRecord macro action can add a new record to a table, populating fields in the
record with data passed from the current table. The reason CreateRecord is not often
used to add a record to the current table is that recursion can occur. Adding a new record
to the current table triggers events such as AfterInsert (described in the “After events”
section, later in this chapter), which may run the CreateRecord action again and again.