An
embedded macro is a macro object that is stored directly in an event property for a form, report, or control.
These macros have two advantages over VBA and macro objects.
- If you have ever copied a control that had code behind it and then wished that the code also was duplicated, this feature is for you.
Because these macros are part of a control's properties, the macro that is associated with a control event is also copied.
- You no longer need separate macro objects that perform small, simple one-off tasks. These macros can be associated directly with an event property.
To create an embedded macro, choose Macro Builder from an event property's Choose Builder dialog box.
Once you create the macro, the event property changes to [Embedded Macro].
To take advantage of these benefits, the wizards in Access 2010 are updated to create embedded macros in the new format database (ACCDB).
This is because VBA code is not allowed to execute in Disabled mode, meaning that wizard-generated code would not run unless a database is trusted.
By using macros, the wizards now allow the application to run as much as possible in
Disabled mode
without failing.
For backward compatibility, VBA code is still created using the wizards in the previous file formats (MDB and ADP), but they have been updated to use the RunCommand method where appropriate.
That's right, the wizards no longer create code that calls DoMenuItem.