Default

Returns or sets a value that determines which CommandButton control is the default command button on a form.

Syntax

object.Default [= boolean]

The parts of the Default property syntax are described in the following table.

Part Description
object An object expression that evaluates to an object.
boolean A Boolean expression that specifies whether the command button is the default, as described in Settings.

Settings

The settings for boolean are described in the following table.

Setting Description
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 the 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.