Command Button Control.
You can use the Cancel property to specify whether a command button is also the Cancel button on a form.
The Cancel property has the following settings.
Setting | Description | Visual Basic |
Yes | The command button is the Cancel button. | True (-1) |
No | (Default) The command button isnt the Cancel button. | False (0) |
You can set this property using the command buttons property sheet, a macro, or Visual Basic.
When a command buttons Cancel property setting is Yes and the form is in the active window, the user can choose the command button by pressing ESC, or pressing ENTER when the command button has the focus, or by clicking the command button.
Note If a text box has the focus when the user presses ESC, any changes made to the data in the text box will be lost, and the original data is restored.
When the Cancel property is set to Yes for one command button, it is automatically set to No for all other command buttons.
Tip For a form that supports irreversible operations, such as deletions, its a good idea to make the Cancel button the default command button. To do this, set both the Cancel property and the Default property to Yes.
Default Property.