Microsoft KB Archive/209511

= ACC2000: How to Use the SendKeys Action to Change Option Menus =

Article ID: 209511

Article Last Modified on 1/26/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209511



This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

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



SUMMARY
In a Microsoft Access macro, a SendKeys action must precede a RunCommand action when you need to send keystrokes to a dialog box. For example, when a RunCommand action opens the Print dialog box to change a printing parameter, the SendKeys keystrokes remain in the buffer. If the SendKeys action follows the RunCommand action, the keystrokes will not run.



MORE INFORMATION
Because opening a dialog box suspends a macro, you must carry out the SendKeys action before the dialog box opens. The following example demonstrates how to open the Print dialog box.  Open an Access 2000 database.  Create a new macro as follows:   Action: SendKeys Keystrokes: %g1%t5{ENTER} Wait: No

Action: RunCommand Command: Print NOTE: If you manually open the Print dialog box, you will see that the keystrokes are to first select the Page Print Range option (that is, %g or ALT+G), insert a 1 into the From box, and then to insert a 5 in the To box (that is, %t or ALT+T).  Close and save the macro as mcrPrint, and double-click the macro to carry it out. The macro carries out its actions, and then opens the dialog box to print out the properties, actions and arguments, and user/group permissions of the mcrPrint macro.

