[ Team LiB ] Previous Section Next Section

Creating an AutoKeys Macro

An AutoKeys macro allows you to redefine keystrokes within a database. With an AutoKeys macro you can map selected keystrokes to a single command or to a series of commands. Follow these six steps to build an AutoKeys macro:

  1. Open a new macro in Design view.

  2. Make sure the Macro Name column is visible.

  3. Enter a key name in the Macro Name column. Access Help defines the allowable keystroke combinations (see Figure 13.23).

    Figure 13.23. A list of valid key stroke combinations for the AutoKeys macro.

    graphics/13fig23.jpg

  4. From the Action drop-down list box, select the macro action you want to associate with the key name. You can apply conditions and arguments just as you do for a normal macro. You can have Access execute multiple commands in one of three ways: associate multiple macro actions with a key name, perform a RunCode action, or perform a RunMacro action.

  5. Continue adding key names and macro actions to the macro as desired. Put one blank line after each key name to improve readability.

  6. Save the macro as AutoKeys. The moment you save the macro, Access places the key names in effect and remaps the keystrokes. The AutoKeys macro goes into effect automatically each time you open the database.

graphics/clock_icon.gif

Generally, it's not a good idea to remap common Windows or Access keystrokes. Users become accustomed to certain keystrokes having certain meanings in all Windows applications. If you try to change the definition of a common keystroke, users will become confused and frustrated. That's why it's important to remap only keystroke combinations that are rarely, if ever, used in Windows.


Task: Creating an AutoExec Macro

graphics/todo_icon.gif

It's time to build an AutoExec macro that acts as the launching point for an application. The macro will start the application by hiding the Database window, displaying a message to the user, and opening the frmClients form.

Build the macro shown in Figure 13.22, following these steps:

  1. Open a new macro in Design view.

  2. Set the first action of the macro to RunCommand.

  3. Set the Command argument to WindowHide. This will hide the Database window when the user runs the macro.

  4. Set the second action of the macro to MsgBox, and set the Message to Welcome to the Client Billing Application. Set Beep to No, Type to Information, and Title to Welcome.

  5. The final action of the macro opens the frmClients form. Set the action to OpenForm and set the FormName to frmClients. Leave the rest of the arguments at their default values.

  6. Close and reopen the database. The AutoExec macro should automatically execute when you open the database.

  7. Close the database and then open it again, holding down the Shift key to prevent the macro from executing.

    [ Team LiB ] Previous Section Next Section