Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


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.
  1. Open an Access 2000 database.
  2. 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).
  3. 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.

↑ Back to the top


References

For more information about how SendKeys works, click Microsoft Access Help on the Help menu, type SendKeys Action in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about SendKeys syntax, click Microsoft Visual Basic Help on the Help menu, type SendKeys Statement in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB209511, kbusage, kbinfo

↑ Back to the top

Article Info
Article ID : 209511
Revision : 3
Created on : 1/26/2005
Published on : 1/26/2005
Exists online : False
Views : 236