ACC: How to Make the AutoKeys Macro Form-Specific

Last reviewed: April 25, 1997
Article 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:

   ARTICLE-ID: Q106183
   TITLE     : ACC: Error Message Using AutoKeys Macro
 

	
	


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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.