Part II: Programming Microsoft Access
384
- Select the options that include error handling and comments, and click Convert.
Access briefly displays each new procedure in the VBA editor window as it’s converted.
When the conversion process completes, the Conversion Finished! message box
appears.
Figure 10.3 shows the newly created VBA module, Converted Macro–mcrOpenContacts. Notice
that the module and the function within the module are named after the converted macro, regard-
less of any other name you might have entered in the Save As dialog box.
FIGURE 10.3
The converted module
When you specify that you want Access to include error processing for the conversion, Access
automatically inserts an On Error statement as the first statement in the procedure, telling Access
to branch to an error handler that displays an appropriate message and then exit the function.
Cross-Reference
Handling errors is covered in Chapter 23.
The statement beginning with DoCmd is the code that Access created from the macro’s actions.
DoCmd methods mimic macro actions and perform important tasks such as opening forms and
reports and setting the values of controls.