To run a macro when the DblClick event occurs, set the OnDblClick property to the name of the macro.
By running a macro when the DblClick event occurs, you can modify a control’s default double-click behavior. For example, you can run a macro before an OLE application is opened in response to double-clicking an embedded object. The macro could display a message asking if the user wants to print or edit the object. You could use a user-defined function to print the object.
You can also use the DblClick event to enable a dialog box to be closed by double-clicking a control instead of clicking the OK button. The DblClick macro runs a Close action for the dialog box. You could also have the macro hide the dialog box by using the SetValue action to set the dialog box’s Visible property to No.
You use the CancelEvent action in a DblClick macro to cancel the default double-click behavior of the control. If the user wanted to print the object mentioned earlier in this topic instead of editing it, you would use a user-defined function to print the object, and then use a CancelEvent action to cancel opening of the OLE application.
Note When you double-click a command button, the following events occur in this order:
Click DblClick Click
The second click may have no effect (for example, if the Click macro opens a modal form). To prevent the second Click event from occurring, you can use the CancelEvent action in the DblClick macro. This sequence of Click, DblClick, Click events occurs when you double-click a command button only, not other types of controls.
DblClick Event — Event Procedures.