OpenModule Action

Description

You can use the OpenModule action to open a specified Visual Basic module at a specified procedure. This can be a Sub procedure, a Function procedure, or an event procedure.

Setting

The OpenModule action uses the following arguments.

Action argument

Description

Module Name

The name of the module you want to open. You can leave this box blank if you want to search all the standard modules in the database for a procedure, and open the appropriate module at that procedure.


Action argument

Description

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

Procedure Name

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


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

Remarks

You can use this action to open an event procedure by specifying the event procedure in the Procedure Name argument. However, you must also specify a module name, because event procedures are private and don’t appear in the global name space. 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.

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

This action has the same effect as selecting a module in the Database window, and then pressing the Design button. 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 Database window and drag it to a macro action row. This automatically creates an OpenModule action that opens the module to the Declarations section.

To run the OpenModule action in Visual Basic, use the OpenModule method of the DoCmd object.

See Also

OpenModule Method, RunCode Action.