OnAction Property

An OnAction event handler runs when you act on a control or when you click a graphic object or a toolbar button. For example, if you create a custom dialog box, you can use the OnAction property of each control in the dialog box to associate the controls with their event handlers. Unlike other OnEvent properties and methods, the OnAction property of a control retains its value between sessions, so you don't have to run a procedure to set its value at the beginning of each session.

The following example causes the StartDialog procedure to run when the dialog box first starts, and it causes the ButtonPressed procedure to run whenever the user presses a button on the first dialog sheet.


With DialogSheets(1)
    .DialogFrame.OnAction = "StartDialog"
    .Buttons.OnAction = "ButtonPressed"
End With

Note that you can also set the OnAction property for a control by selecting the control, clicking Assign Macro on the Tools menu, and entering a procedure name in the Macro Name/Reference box.

For more information about using the OnAction property, see Chapter 8, "Controls and Dialog Boxes," and Chapter 9, "Menus and Toolbars," or see the appropriate topic in Help.