Make a command button the Cancel button

When the Cancel property of a command button on a form is set to Yes and the form is the active form, you can choose the command button by clicking it, pressing the ESC key, or pressing ENTER when the command button has the focus. When the Cancel property is set to Yes for one command button, it's automatically set to No for all other command buttons on the form. Only one button can be the default on a form. This procedure does not apply to a command button on a data access page.

  1. Open a form in Design view.
  2. Click the command button, and then click Properties on the Form Design toolbar to open the command button's property sheet.
  3. In the Cancel property box, click Yes.

Note   To have a Cancel button cancel all the actions that have taken place in a form or dialog box, you need to write a macro or event procedure and attach it to the OnClick property of the button.

Tip

For a form that allows irreversible operations, such as deletions, it's 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.