Microsoft KB Archive/208923

= ACC2000: How to Set Defaults for the Find and Replace Dialog Box =

Article ID: 208923

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q208923



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

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



SUMMARY
This article describes how to set different default settings for the Find and Replace dialog box in Microsoft Access 2000.



MORE INFORMATION
When you click Find on the Edit menu in Form view, the Find and Replace dialog box appears with the following default settings:

Find What:

Look In: current field

Match: Whole Field

Search: All

Match Case:

Search Fields As Formatted:

To alter these settings, start the Find and Replace dialog box with the RunCommand and use the SendKeys action to select alternate settings. For example, you can start the Find and Replace dialog box by using a macro with the following actions:   Action       Action Argument --  SendKeys     Keystrokes: %ha%n Wait: No  RunCommand   Command: Find This macro can then be assigned to a command button, a button on a form, or to an event on a form. When you run this macro, the Find and Replace dialog box appears with Any Part Of Field selected in the Match box. The keystrokes sent by the SendKeys action are as follows:
 * ALT+H to select the Match box setting
 * "a" to select Any Part Of Field setting
 * ALT+N to select the Find What box

The SendKeys action must come before the call to open the dialog box, even though it may seem that the call to open the dialog box should come first. However, if you place the call to open the dialog box first, the macro runs the RunCommand action and then waits for the dialog box to be closed before continuing to the next action (the SendKeys action), sending your keystrokes to the form.

The following table lists which keystrokes to send to select various items in the Find and Replace dialog box:   Option                       Setting             Keystrokes ---  Match                        Any Part of Field   %ha Match                       Start of Field      %hs Match Case                           %c Search Fields as Formatted           %o Search                      Up                  %su Search                      Down                %sd You can combine these keystrokes to make multiple selections. For example, the following actions open the Find and Replace dialog box with Start Of Field selected in the Match box; select Up in the Search box; and set the focus to the Find What box:   Action       Action Argument --  SendKeys     Keystrokes: %hs%su%n Wait: No  RunCommand   Command: Find

