OpenFunction Action

In a Microsoft 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.

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 window 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, Access looks for the function with this name first in the library database, 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 clicking the Open button or Design button after clicking Queries  under Objects, and then selecting a user-defined function in the Database window.

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

Tips

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