OpenVisualBasicModule Macro Action

You can use the OpenVisualBasicModule macro action in Access databases to open a specified Visual Basic for Applications (VBA) module at a specified procedure. This can be a Sub procedure, a Function procedure, or an event procedure.

Note: Beginning in Access 2010, the OpenModule macro action was renamed to OpenVisualBasicModule.

Note: This action will not be allowed if the database is not trusted.

Note: The OpenVisualBasicModule macro action isn't available in Access web apps.


The OpenVisualBasicModule macro action has the following arguments.

Action argument


Module Name

The name of the module you want to open. Select the name of the module in the drop-down list. You can leave this argument blank if you want to search all the standard modules in the database for a procedure and open the appropriate module at that procedure.

If you run a macro containing the OpenVisualBasicModule action in a library database, Access first looks for the module with this name in the library database, and then in the current database.

Procedure Name

The name of the procedure you want to open the module to. If you leave this argument blank, the module opens to the Declarations section.

Note: You must enter a valid name in either the Module Name or Procedure Name argument.


You can use this macro action to open an event procedure by specifying the Module Name argument and the Procedure Name argument. For example, to open the Click event procedure of the PrintInvoice button on the form Orders, set the Module Name argument to Form.Orders and set the Procedure Name argument to PrintInvoice_Click. To view the event procedure for a form or report, the form or report must be open.

Similarly, to open a procedure in a class module, you must specify the module name, although the class module does not have to open.

To open a private procedure, the module containing it must be open.

This action has the same effect as right-clicking a module in the Navigation Pane and then clicking Design View. This action also enables you to specify a procedure name and to search the standard modules in a database for procedures.

Tip:  You can select a module in the Navigation Pane and drag it to the macro window. This automatically creates an OpenVisualBasicModule action that opens the module to the Declarations section.

To run the OpenVisualBasicModule action in a VBA module, use the OpenModule method of the DoCmd object.

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!