Previous Page
Next Page

Hack 3. Work Fast and Avoid Typos

Save time and avoid mistakes by using simple keystrokes for entering the date, time, or other commonly used entries.

The mouse is nice, but nothing beats getting around an application faster than keyboard shortcuts. Ctrl-C for copy, Ctrl-V for paste, and so on, are pretty familiar. How about keyboard shortcuts for entering the date, time, and other data? Using these shortcuts will save valuable time when you are in a rush to finish a project. And how often are you not in a rush?

1.4.1. Know Thy Shortcuts

Table 1-1 summarizes useful keyboard shortcuts to use within your Access applications. This isn't an exhaustive list of keyboard shortcutsnot by a long shot! You can use the Access Help system to find all the shortcuts. The ones presented in Table 1-1 are specific shortcuts for entering data.

Table 1-1. Keyboard shortcuts for entering data


Keyboard shortcut

Enter the current time.


Enter the current date.


Insert data from the same field in the previous record.


Insert the default value for the field.


Insert a new line in a text or memo field.


Enter a new record.


Paste the contents of the Windows clipboard.


These shortcuts are quite handy. Have you ever forgotten the current date when you had to enter it in a field? Well, all you need to remember now is the keyboard shortcut to enter the current date. Which brings us to the next point…

1.4.2. Remember Where to Reference Shortcuts

It takes time to memorize a group of shortcuts, so the next best thing is to boil it down to memorizing just one. The twist here is to have the list of keyboard shortcuts available on a form that you can easily display usingyou guessed ita keyboard shortcut. However, you need to create this shortcut.

Using the AutoKeys Macro

The AutoKeys macro lets you assign database actions to custom keyboard shortcuts. You can assign actions to the function keys, to key combinations such as Ctrl-A, and to the Insert and Delete keys. You must follow a strict syntax, however: a carat (^) represents the Ctrl key, and a plus sign (+) represents the Shift key. You enter regular keys verbatim, and you enclose function keys and special keys (Insert and Delete) in braces ({}). Here are a few examples:

  • ^A sets an action to Ctrl-A.

  • {F9} sets an action to the F9 function key.

  • +{F9} sets an action to Shift-F9.

  • {INSERT} sets an action to the Insert key.

When you set a custom shortcut to an existing default shortcut, the custom shortcut overrides the default one. Therefore, you can override common keyboard shortcuts, such as Ctrl-V (paste), and instead provide your own.

The syntax statements are placed in the Macro Name column, and the appropriate actions are set in the Action column. The only other requirement is that the macro is actually named AutoKeys.

Figure 1-7 shows a form that lists the keyboard shortcuts. The form is based on a table that holds the shortcuts and their descriptions in two respective fields. An alternative is to just use label controls in which the shortcuts and descriptions have been entered.

Figure 1-7. A quick-reference form for keyboard shortcuts

A function key is easy enough to remember. F9 is a good one to target because it isn't commonly used. By contrast, F1 isn't a great choice because it's the standard for entering the Help system. To establish a custom keyboard shortcut, use the special AutoKeys macro. The AutoKeys macro is activated at startup in the same fashion as the AutoExec macro.

Figure 1-8 shows the AutoKeys macro set up with a few custom keyboard shortcuts. Pressing F9 opens the frmKeyboardShortcuts form shown in Figure 1-7.

Figure 1-8. Using the AutoKeys macro to set up custom keyboard shortcuts

    Previous Page
    Next Page