RunCode Action

Description

You can use the RunCode action to run a Visual Basic Function procedure.

Setting

The RunCode action uses the following argument.

Action argument

Description

Function Name

The name of the Visual Basic Function procedure to execute. Put any function arguments in parentheses. This is a required argument.


Note To use the Expression Builder to select a function for this argument, click the Build button to the right of the Function Name box. Click a function in the list in the Expression Builder.

Remarks

The user-defined Function procedures are stored in Microsoft Access modules.

You must include parentheses, even if the Function procedure doesn’t have any arguments, as in the following example.


TestFunction()

Unlike user-defined function names used for event property settings, the function name in the Function Name argument does not begin with an equal sign (=).

Microsoft Access ignores the return value of the function.

Tip To run a Sub procedure or event procedure written in Visual Basic, create a Function procedure that calls the Sub procedure or event procedure. Then use the RunCode action to run the Function procedure.

If you use the RunCode action to call a function, Microsoft Access looks for the function with the name specified by the Function Name argument in the standard modules for the database. However, when this action runs in response to choosing a menu command on a form or report or in response to an event on a form or report, Microsoft Access looks for the function first in the form or report module and then in the standard modules.

This action isn’t available in Visual Basic. Run the desired Function procedure directly in Visual Basic.

See Also

Eval Function, OpenModule Action.