OpenFunction Macro Action

In an Access project, you can use the OpenFunction 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. For more information about enabling macros, see the links in the See Also section of this article.

Setting

The OpenFunction action has the following arguments.

Action argument Description
Function Name The name of the user-defined function to open. The Function Name box in the Action Arguments section of the Macro Builder pane shows 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, Microsoft Office Access 2007 first looks for the function with this name in the library database, and then in the current database.

View The view in which the user-defined function will open. Click 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. Click 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.

Remarks

This 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.

Tips  

  • You can select a user-defined function in the Navigation Pane and drag it to a macro action row. 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 SetWarning action to suppress the display of these messages.

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

See Also

  • Enable or disable macros in Office documents