Chapter 30: Using Access Macros
1077
FIGURE 30.20
An embedded macro doesn’t have a name. The title bar displays the control and the
event in which the macro is embedded.
Using an embedded macro has some advantages over using an event procedure containing VBA
code. If you copy the button and paste it on another form, the embedded macro goes with it. You
don’t have to copy the code and paste it as a separate operation. Similarly, if you cut and paste the
button on the same form (for example, moving it onto a Tab control), you don’t have to reattach
the code to the button.
Embedded macros offer another improvement to macros in previous versions. If you automate
your application with embedded macros, and import a form or report into another database, you
don’t have to worry about importing the associated macros into the database as well. By using
embedded macros, all the automation moves with the form or report. This makes maintaining and
building applications easier.
Macros versus VBA Statements
In Access, macros often offer an ideal way to take care of many details, such as running reports and
forms. You can develop applications and assign actions faster using a macro because the arguments
for the macro actions are displayed with the macro (in the bottom portion of the macro window).
You don’t have to remember complex or difficult syntax.
Several actions you can accomplish with VBA statements are better suited for macros. The follow-
ing actions tend to be more efficient when they’re run from macros:
l Using macros against an entire set of records with action queries — for example, to
manipulate multiple records in a table or across tables (such as updating field values or
deleting records)
l (^) Opening and closing forms
l Running reports