ACC2000: How to Use the SendKeys Action to Change Option Menus (209511)



The information in this article applies to:

  • Microsoft Access 2000

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.
  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.

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.

Modification Type:MinorLast Reviewed:1/26/2005
Keywords:kbinfo kbusage KB209511