From the course: Access 2016: Advanced Tips and Tricks

Add customized shortcut keys

From the course: Access 2016: Advanced Tips and Tricks

Start my 1-month free trial

Add customized shortcut keys

- Power users of any system love having shortcuts to getting their work done. The users of your database will be no exception and once they've gotten used to the workflows that you've set up for them, they might appreciate even faster and more efficient ways to accomplish common tasks. We can provide multiple ways of accomplishing something in the database by providing power users with keyboard shortcuts that activate button controls. This can make navigating around the database even faster. Let me add a couple of shortcut keys to the buttons here on our main menu form. To do that I'll right click on the main menu and go into design view. The shortcut keys in Access will be activated by pressing and holding the alt key on the keyboard followed by a letter code that we're going to define. All we need to do is define which letter we want to activate each of these different buttons. For this first button, the open employee directory one, I want the letter E key to be the shortcut key for this button. In order to implement this, what I need to do is select the button, go over here to the format tab and find the caption property. Then right before the letter E here, I'm going to put in an ampersand character. That's Shift + 7 on your standard US keyboard. After pressing Enter to finalize that text entry, you'll notice that the button over here has an underscore underneath the letter E. That indicates that the letter E is the shortcut key for this particular button. Let's add shortcut keys to the enter a new customer button. For this one, I want the letter C key to be the shortcut. So once again, over here on the caption property, right before the letter C I'm gonna type in the ampersand character. And then we'll see that this letter C here is now underlined. Let's do the same thing for the product listing, and this time we'll choose the letter P key. And finally, for the exit database, we'll choose the letter X key. So click right here, and put the ampersand right before the letter X. Let's go ahead and press Control + S on the keyboard to save our changes and we'll switch our view back into form view and test it out. Rather than going over and clicking on the button, I'm gonna press Alt + E to activate the employee directory. That should open up the employee directory form here. Now what I wanna do is create another shortcut key to return to the main menu from this form. Let's go ahead and right click on this and go into design view. And for this button, I'm gonna click on the button and I'm gonna activate the letter M key to return to main menu. Once again, we'll just put an ampersand right before the M in main menu. I'll press Control + S to save my change and we'll go back into form view to test it out. Now I'll press Alt + M and that will return me back to the main menu. Now there's two other ways that we can implement shortcut keys on our buttons. Let's take our main menu back into design view. We can specify a single button that we activated by the Enter key on our keyboard, as well as a button that'll be activated by the Escape key on the keyboard. These properties can be found over here on the other tab. So let's say that I also want the open employee directory button to be activated by the Enter key. That's gonna be this default property right here. I'm gonna change it from no to yes. Once again I'll save my changes by pressing Control + S on the keyboard. And we'll switch our view into form view. Now instead of pressing Alt + E I'll just press Enter. That'll activate that button and return me to the employee directory. Now for the return to main menu button I wanna activate this with the Escape key on my keyboard. Let's take this into design view and we'll click on the button and on the other tab, we'll find the cancel property here. I'll set that to yes. By changing the cancel property to yes, we've established this button can be activated by the Escape key on your keyboard. Once again I'll press Control + S to save the change and go back into form view. Now instead of pressing Alt + M, I'll just tap the Escape key and that should take me back to the main menu. At this point, I wanna make sure that my entire database follows the same user conventions as far as the shortcut keys go throughout the various form objects. So let's go into the enter a new customer form, I'll press Alt + C to activate that button. And then we'll add the same shortcut keys to this return to main menu button. So I'll right click on the tab, go into design view, I'll click here on the button, and on the format tab we'll put an ampersand before the letter M, as well as on the other tab, we'll change the cancel property to yes. I'll save my changes, and then we'll go back into form view. Now I can tap the Escape key to return to the main menu on this one and press Alt + P to go into the product listing. Once again, we'll make the same changes to this return to main menu button. I'll go into design view, I'll click on the button, on the format tab I'll put an ampersand before the letter M, and on the other tab we'll change its cancel property to yes. Now I have consistent shortcut keys that'll be active throughout the entire database. Let's go ahead and save this form and go into form view. Now I can tap the Escape key to go back to the main menu. And now from any form in my system, I can get there using shortcut keys. I'll press Alt + E to go into the employee directory and Escape to get back. Alt + C to go to my customer listing, and Escape or Alt + M to go back. So that's how we can activate our button controls using shortcut keys. Simply place an ampersand character before the letter you want to use in the button's caption, and you've instantly provided a secondary and more efficient way to activate the action. Alternatively, enable the default or cancel properties to make the buttons respond to either the Enter or Escape keys on your keyboard.

Contents