ACC: Using SendKeys to Change Option Menus

ID: Q101074


The information in this article applies to:


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 
Issue type        : kbinfo 

Last Reviewed: March 25, 1999