SendKeys Action

Description

You can use the SendKeys action to send keystrokes directly to Microsoft Access or to an active Microsoft Windows-based application.

Setting

The SendKeys action uses the following arguments.

Action argument

Description

Keystrokes

The keystrokes you want Microsoft Access or the application to process. You can type up to 256 characters. This is a required argument.

Wait

Specifies whether the macro should pause until the keystrokes have been processed. Click Yes to pause or No not to pause. The default is No.


Remarks

Microsoft Access processes the keystrokes it receives through the SendKeys action exactly as if you had typed them directly in a Microsoft Access window.

To specify the keystrokes, use the same syntax as the SendKeys statement.

You can use this action to enter information in a dialog box, particularly if you don’t want to interrupt the macro to respond manually to the dialog box. Some Microsoft Access actions, such as Print and FindRecord, automatically select the options in certain frequently used dialog boxes. You can use the SendKeys action to select the options in less commonly used dialog boxes.

Notes

  • Because the dialog box suspends the macro, you must put the SendKeys action before the action that causes the dialog box to open and set the Wait argument to No to avoid breaks in the processing.
  • The timing of the keystrokes reaching Microsoft Access or another application can be tricky. As a result, it’s recommended that if there is some other method (such as the FindRecord action) you can use to achieve a desired task, use that method rather than using the SendKeys action to fill in the options in a dialog box.

If you want to send more than 256 characters to Microsoft Access or another Windows-based application, you can use several SendKeys actions in succession in a macro.

Using the SendKeys action to send keystrokes triggers the appropriate KeyDown, KeyUp, and KeyPress events. Sending non-ANSI keystrokes (such as a function key) doesn’t trigger the KeyPress event.

This action isn’t available from Visual Basic. Use the SendKeys statement instead.

See Also

GoToControl Action; KeyDown, KeyUp Events; KeyPress Event; SelectObject Action; SendKeys Statement; SetValue Action.