Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Applies to

CommandButton Object

CustomControl Object

You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.

expression.Default

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

The Default property uses the following settings.

Setting

Visual Basic

Description

Yes

True

The command button is the default button.

No

False

(Default) The command button isn't the default button.

You can set this property by using the command button's property sheet, a macro, or Visual Basic for Applications (VBA) code.

When the command button's Default property setting is Yes and the Form window is active, the user can choose the command button by pressing ENTER (if no other command button has the focus) as well as by clicking the command button.

Only one command button on a form can be the default button. When the Default property is set to Yes for one command button, it is automatically set to No for all other command buttons on the form.

tip

For a form that supports irreversible operations, such as deletions, it is a good idea to make the Cancel button the default command button. To do this, set both the Default property and the Cancel property to Yes.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×