Microsoft KB Archive/130856

= ACC: How to Make the AutoKeys Macro Form-Specific =

Article ID: 130856

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q130856



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



SUMMARY
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:

 Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0).  Create the following macro and save it as Test1:

     Macro Name   Action ---     Test1        MsgBox

Test1 Actions ---     MsgBox Message: The AutoKeys macro worked successfully!   Create another macro and save it as AutoKeys:

     Macro Name   Condition                                  Action ^m          [Screen].[ActiveForm].[Name]="employees"   RunMacro

^m Actions RunMacro Macro Name: Test1  Open the Employees form in Form view. Press CTRL+M. Note that the message box specified in step 2 appears. Click OK to close the message box.</li> Open the Categories form in Form view.</li> 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.</li></ol>

<div class="references_section">