Convert Embedded Macros in Access 2007

<< Click to Display Table of Contents >>

Navigation:  VBA >

Convert Embedded Macros in Access 2007

Convert macros that are attached to a form or report

This process converts to VBA any macros that are referred to by (or embedded in) a form or report (or any of its controls) and adds the VBA code to the form or report's class module. The class module becomes part of the form or report and moves with the form or report if it is moved or copied.

1.In the Navigation Pane, right-click the form or report, and then click Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.).

2.On the Database Tools tab, in the Macro group, click either Convert Form's Macros To Visual Basic or Convert Report's Macros To Visual Basic.

3.In the Convert form macros or Convert report macros dialog box, select whether you want Access to add error handling code to the functions it generates. Also, if you have any comments in your macros, select whether you want to have them included as comments in the functions. Click Convert to continue.

4.If no class module exists for the form or report, Access creates one and adds a procedure to the module for each macro that was associated with the form or report. Access also changes the event properties of the form or report so that they run the new VBA procedures instead of the macros.

5.To view and edit the VBA code:

6.While the form or report is still open in Design view, if the property sheet is not already displayed, press F4 to display it.

7.On the Event tab of the property sheet, click in any property box that displays [Event Procedure], and then click . To view the event properties for a specific control, click the control to select it. To view the event properties for the entire form or report, select Form or Report from the drop-down list at the top of the property sheet.

8.Access opens the Visual Basic Editor and displays the event procedure in its class module. You can scroll up or down to view any other procedures that are in the same class module.

 

Read more on this page at Microsoft http://office.microsoft.com/en-au/access/HA012142131033.aspx