ACC: Using SendKeys to Change Option Menus

Last reviewed: April 3, 1997
Article ID: Q101074
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

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

In a Microsoft Access macro, a SendKeys action must precede the DoMenuItem action when you need to send keystrokes to a dialog window. For example, when a DoMenuItem action opens the Print dialog to change a printing parameter, the SendKeys keystrokes remain in the buffer and do not run if the SendKeys action follows the DoMenuItem action.

MORE INFORMATION

Because opening a dialog window suspends a macro, you must execute the SendKeys action before the dialog opens. The following example demonstrates opening the Print dialog. Try running this macro from a button on a form.

In Microsoft Access 97

   Macro Name     Action         Comment
   ---------------------------------------------------------------
   TestSendKeys   SendKeys       Store keystrokes for Print dialog
                  RunCommand     Open Print dialog

   TestSendKeys Actions
   ----------------------------
   SendKeys
      Keystrokes: %g1%t5{ENTER}
      Wait: No
   RunCommand
      Command: Print

In Microsoft Access 7.0

   Macro Name     Action         Comment
   ---------------------------------------------------------------
   TestSendKeys   SendKeys       Store keystrokes for Print dialog
                  DoMenuItem     Open Print dialog

   TestSendKeys Actions
   ----------------------------
   SendKeys
      Keystrokes: %g1%t5{ENTER}
      Wait: No
   DoMenuItem
      Menu Bar: Form
      Menu Name: File
      Menu Command: Print

In Microsoft Access 1.x and 2.0

   Macro Name     Action         Comment
   ---------------------------------------------------------------
   TestSendKeys   SendKeys       Store keystrokes for Print dialog
                  DoMenuItem     Open Print dialog

   TestSendKeys Actions
   ----------------------------
   SendKeys
      Keystrokes: %p1%t5{ENTER}
      Wait: No
   DoMenuItem
      Menu Bar: Form
      Menu Name: File
      Menu Command: Print

REFERENCES

For more information about SendKeys, search the Help Index for "SendKeys action."

For more information about SendKeys keystroke syntax, search the Help Index for "SendKeys statement."


Keywords : kbusage McrActn
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


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 3, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.