procedure.
- Create a macro.
- In the Database window, click Macros under Objects.
- Click the New button on the Database window toolbar.
- In a blank action row, click MsgBox in the action list, and then set the action arguments.
- Click Save to save the macro.
- To test the macro, click Run on the toolbar.
- Create a Visual Basic procedure.
-
In the Database window, click Modules under Objects, and then click New on the Database window toolbar.
- Declare the procedure by typing the Sub statement.
- Type a procedure name, immediately followed by any arguments in parentheses. For example, the following declaration for the ShowEvent Sub procedure specifies EventName as an argument:
Sub ShowEvent(EventName As String)
-
- Add an assignment statement to the procedure that assigns the value returned by the MsgBox function to a variable. The function returns different values depending on the button a user clicks in the message box. Your procedure can then perform different operations based on the value returned.
For example, the following assignment statement runs the MsgBox function, displaying a message, and assigns the value returned by the function to the variable RetValue:
RetValue = MsgBox("Continue?", vbOKCancel)
- To test, run the procedure by clicking Run Sub/UserForm on the toolbar, select the procedure in the Macros dialog box, and then click Run.