Cancel

Returns or sets a value indicating whether a command button is the Cancel button on a form. This command button can be the CommandButton control.

Syntax

object.Cancel [= boolean]

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

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

Settings

The settings for boolean are described in the following table.

Setting Description
True The CommandButton control is the Cancel button.
False (Default). The CommandButton control is not the Cancel button.

Remarks

Use the Cancel property to give the user the option of canceling uncommitted changes and returning the form to its previous state.

Only one CommandButton control on a form can be the Cancel button. When the Cancel property is set to True for one CommandButton, it is automatically set to False for all other CommandButton controls on the form. When a CommandButton control's Cancel property setting is True and the form is the active form, the user can choose the CommandButton by clicking it, pressing the ESC key, or pressing ENTER when the button has the focus.

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