Creating Access Keys
|Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.|
Inside Microsoft Access
A Publication of The Cobb Group
Published February 1998
When you see an underlined character in a menu option, you probably know that you can press this character along with the [Alt] key to execute the menu command. These underlined characters are called access keys. In this article, we'll show you how to define an access key.
On This Page
A sample form
To demonstrate how to create an access key, we'll use the simple form shown in Figure A. Specifically, we'll assign access keys to the two controls.
To create the form, begin by selecting the Forms tab and clicking the New button in the Database window. Then, double-click Design View in the New Form dialog box. (Versions 2.0 users click the Blank Form button in the New Form dialog box.) Next, add a text box and a command button to the blank form by clicking the appropriate button in the Toolbox and then clicking inside the form. (If Access launches the Command Button Wizard, simply click Cancel.)
An access key for the command button
Now you're ready to create an access key for the command button. To do so, you simply select a letter from the button's Caption property and insert an ampersand before it. For example, we chose the letter C in the default name Command1. (Version 2.0 will use the default name Button1.) To make this letter the access key, first open the button's property sheet by double-clicking the button. Then, locate the Caption property's field and change the setting from Command1 to &Command1, as shown in Figure B.
An access key for the text box
Assigning an access key to the text box is a little trickier, since it doesn't have a Caption property. However, it does have a label control—and that's where you'll insert the ampersand. First, select the text box's label and open its property sheet. Next, locate the Caption property and insert an ampersand before the T character—changing it from Text0 to &Text0. (Version 2.0 will use the default caption Field0.)
Using the access keys
Now that you've defined the access keys, click the View button (INSERT ViewFormDesign) on the Form Design toolbar (Form View—ICON—in 2.0) so you can see how they work. Notice that the T and C are both underlined, as shown in Figure C. To switch between the two controls, simply press the appropriate access key: Press [Alt]C to select the button; press [Alt]T to select the text box.
The article entitled "Creating Access Keys" was originally published in Inside Microsoft Access, February 1998. Copyright © 1998, The Cobb Group, 9420 Bunson Parkway, Louisville, KY 40220. All rights reserved. For subscription information, call the Cobb Group at 1-800-223-8720.
We at Microsoft Corporation hope that the information in this work is valuable to you. Your use of the information contained in this work, however, is at your sole risk. All information in this work is provided "as is," without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement , and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Microsoft Corporation. Microsoft Corporation shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.