Part III: More-Advanced Access Techniques
706
query very specific. When using the equal sign, the user is required to enter the full text for each
value (New York, for example).
Adding a default button
There should be a button on the form that’s automatically selected if the user presses the Enter key
while the dialog box is open. The default button doesn’t have to be selected by the user to be trig-
gered; Access automatically fires the default button’s Click event as the user presses the Enter key.
For example, the user enters 17 in the Customer ID text box and presses Enter. Unless a default
button is specified, the input cursor simply drops down to the City text box. If you’ve designated
the Run Query button as the dialog box’s default, Access interprets the Enter key press as a Click
event for the Run Query button.
Set the Run Query’s Default property to Yes to make it the default for this dialog box. Only one
button on a form can have its Default property set to Yes — if you move to the Cancel button
and set its Default property to Yes, Access silently changes the Run Query’s Default property
to No.
Normally, the designated default button is on the left of the form. If you’ve arranged the command
buttons vertically on a form, the top button should be the default.
You should select a button that won’t cause trouble if accidentally triggered as the default for a
form. For example, to avoid the risk of losing data, it’s probably not a good idea to set a button
that performs a delete action query as the default. In this case, you might decide to make the
Cancel button the default.
Setting a Cancel button
The Cancel button on a form is automatically selected if the user presses the Esc key while the
form is open. In most cases, you simply want the dialog box to disappear if the user hits the Esc
key while the dialog box is open.
Set a button’s Cancel property to designate it as the form’s Cancel button. In this example, cmd-
Cancel has been designated the dialog box’s Cancel button. As with the default button, only one
button on a form can be the Cancel button. Access triggers the Cancel button’s On Click event
whenever the user presses the Esc key.
Removing the control menu
After you’ve designated default and Cancel buttons, you have no need for the control menu button
in the upper-left corner of the form. Set the form’s Control Box property to No to hide the con-
trol menu button. When the control menu box is removed, the user will have to use the Cancel or
Run Query buttons to remove the form from the screen.