ACC: How to Make the AutoKeys Macro Form-Specific

ID: Q130856


The information in this article applies to:
  • Microsoft Access versions 2.0, 7.0, 97


SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article demonstrates how you can create an AutoKeys macro to work with a specific form rather than with all the objects in the database.


MORE INFORMATION

When you assign a set of actions to a specific key combination in an AutoKeys macro, the key-combination assignment is in effect throughout the database. However, you can limit the scope of the key-combination assignment by using a condition in the AutoKeys macro.

To make the AutoKeys macro work only with a specific form, follow these steps:

  1. Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0).


  2. Create the following macro and save it as Test1:
    
          Macro Name   Action
          -------------------
          Test1        MsgBox
    
          Test1 Actions
          ---------------------------------------------------
          MsgBox
             Message: The AutoKeys macro worked successfully! 


  3. Create another macro and save it as AutoKeys:
    
          Macro Name   Condition                                  Action
          ----------------------------------------------------------------
          ^m           [Screen].[ActiveForm].[Name]="employees"   RunMacro
    
          ^m Actions
          --------------------
          RunMacro
             Macro Name: Test1 


  4. Open the Employees form in Form view.


  5. Press CTRL+M. Note that the message box specified in step 2 appears. Click OK to close the message box.


  6. Open the Categories form in Form view.


  7. Press CTRL+M. Note that the message box specified in step 2 does not appear because the Categories form does not meet the condition you set in the AutoKeys macro.



REFERENCES

For more information about AutoKeys, search the Help Index for "AutoKeys macro group."

For more information about "conditions in macros", search the Help Index for "macros, conditional expressions."

For information about troubleshooting errors in the AutoKeys macro, please see the following article in the Microsoft Knowledge Base:

Q106183 ACC: Error Message Using AutoKeys Macro

Keywords : kbusage McrHowto
Version : 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: April 30, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.