Default

This property returns and sets a value that determines which CommandButton control is the default command button on a form.

Syntax

object.Default [= Boolean]

Parameters

object
Object expression that evaluates to a CommandButton control.
Boolean
Boolean expression that specifies whether the command button is the default. Following are the settings for Boolean:
True
The CommandButton is the default command button.
False (default)
The CommandButton is not the default command button.

Remarks

Only one command button on a form can be the default command button. When Default is set to True for one command button, it is automatically set to False for all other command buttons on the form. When the command button's Default property setting is True and its parent form is active, the user can choose the command button (invoking its Click event) by pressing ENTER. Any other control with the focus does not receive a keyboard event (KeyDown, KeyPress, or KeyUp) for the ENTER key unless a user has moved the focus to another command button on the same form. In this case, pressing ENTER chooses the command button that has the focus instead of the default command button.

For a form or dialog box that supports an irreversible action such as a delete operation, make the Cancel button the default command button by setting its Default property to True.