Code Examples For RunCommand Constants

Open Find Dialog

acCmdFind

This example opens the Find dialog box. The keystrokes sent by the SendKeys action are: ALT+H to select the Match box, "a" to select Any Part Of Field, and ALT+N to select the Find What box. For more information on this topic see ACC: How to Set Defaults for the Find Dialog Box on the Microsoft Knowledge Base.

To try this example out, create a button on a form and call it cmdFind. Put the following code behind the On Click event.

'***************** Code Start *******************
SendKeys information
'This code was adapted by Terry Wickenden.
'from a macro example in the Microsoft Knowledge Base

Private Sub cmdFind_Click()

  Screen.PreviousControl.SetFocus
  SendKeys "%ha%n", False
  DoCmd.RunCommand acCmdFind

End Sub

'****************** Code End ********************