Saturday, May 7, 2022

OpenFunction Macro Action [MS]

In an Access project (*.adp), you can use the OpenFunction macro action to open a user-defined function in Datasheet view, inline function Design view, SQL Text Editor view (for a scalar or table user-defined function), or Print Preview. This action runs the user-defined function when opened in Datasheet view. You can also select the data entry mode for the user-defined function and restrict the records that the user-defined function displays.

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

Note: Access 2010 is the last version that supports Access data projects.


The OpenFunction macro action has the following arguments.

Action argument


Function Name

The name of the user-defined function to open. The Function Name box displays all user-defined functions in the current database. This is a required argument.

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


The view in which the user-defined function will open. Select Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.

Data Mode

The data entry mode for the user-defined function. This applies only to user-defined functions opened in Datasheet view. Select Add (the user can add new records but can't view or edit existing records), Edit (the user can view or edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.


This macro action is similar to double-clicking a user-defined function in the Navigation Pane, or right-clicking the function in the Navigation Pane and selecting a view.

Switching to Design view while the user-defined function is open removes the Data Mode argument setting for the user-defined function. This setting is not in effect, even if the user returns to Datasheet view.


  • You can select a user-defined function in the Navigation Pane and drag it onto the macro design window. This automatically creates an OpenFunction action that opens the user-defined function in Datasheet view.

  • If you don't want to display the system messages that normally appear when a user-defined function is run (indicating it is a user-defined function and showing how many records will be affected), you can use the SetWarnings macro action to suppress the display of these messages.

To run the OpenFunction macro action in a Visual Basic for Applications (VBA) module, use the OpenFunction method of the DoCmd object.

No comments:

Post a Comment

Search This Blog

Upload files or photos to OneDrive for Windows mobile devices [MS]

OneDrive Mobile and Mac Mobile ...