Microsoft KB Archive/120912

= ACC97: How to Set Defaults for the Find Dialog Box =

Article ID: 120912

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition
 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q120912



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



SUMMARY
This article describes two methods that you can use to invoke the Find dialog box with different default settings.



MORE INFORMATION
When you click Find on the Edit menu in Form view, the Find dialog box appears with the following default settings.  In Access versions                   In version 7.0 and Access 97 1.0, 1.1, and 2.0 ---     --  Where: Match Whole Field             Search: All Search In: Current Field            Match: Whole Field Match Case:                 Match Case: Search Fields As Formatted: Search fields as formatted: Direction: Down                     Search only current field:

Method 1
In version 7.0 and Access 97, you can change these settings through the Edit/Find tab of the Options dialog box. To modify the settings through the Options dialog box, follow these steps:
 * 1) On the Tools menu, click Options and then click the Edit/Find tab.
 * 2) Under the "Default Find/Replace Behavior" section, change the option buttons to reflect the default behavior that you want.

The settings for each Search option are listed below.

Fast Search
In version 7.0 and Access 97 -- Search: All Match: Whole Field Match Case: Search fields as formatted: Search only current field:

General Search
In version 7.0 and Access 97 -- Search: All Match: Any Part of Field Match Case: Search fields as formatted:  Search only current field:

Start of Field Search
In version 7.0 and Access 97 -- Search: All Match: Start of Field Match Case: Search fields as formatted: Search only current field:

Method 2
You can also change these settings by invoking the Find dialog box with the DoMenuItem action (or RunCommand in Access 97) by using the SendKeys action to select different settings. For example, you can invoke the Find dialog box by using a macro with the following actions:   In Access 97:

SendKeys Keystrokes: %ha%n Wait: No     RunCommand Command: Find

In Access versions 2.0, 1.0, and 1.1, and in version 7.0:

SendKeys Keystrokes: %ha%n Wait: No     DoMenuItem MenuBar: Form MenuName: Edit Command: Find This macro can then be assigned to a command button, to a button on a form, or to an event on a form. When you run this macro, the Find dialog box appears with Any Part Of Field selected in the Match box (or Where box in versions 2.0, 1.0, and 1.1). 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

The SendKeys action must come before the call to open the dialog box, although it may seem that the call to open the dialog box must come first. However, if you put the call to open the dialog box first, the macro runs the RunCommand action and then waits for the dialog box to close before the macro then continues to the next action (the SendKeys action). The SendKeys action sends your keystrokes to the form.

The following table lists the keystrokes to send to select various items in the Find dialog box.

In Access 97 and version 7.0:   Option                       Setting             Keystrokes ---  Match                        Any Part of Field   %ha Match                       Start of Field      %hs Search Only Current Field             %e Match Case                           %c Search Fields as Formatted           %o Search                      Up                  %ru Search                      Down                %rd In Access versions 2.0, 1.0, and 1.1:   Option                       Setting             Keystrokes ---  Where                        Any Part Of Field   %ha Where                       Start Of Field      %hs Search In                   All Fields          %l Match Case                           %s Search Fields As Formatted           %o Direction                   Up                  %u You can combine these keystrokes to make multiple selections. For example, the following actions open the Find dialog box with Start Of Field selected in the Match box. Then, the actions clear the Search Only Current Field box (or select the All Fields option in version 2.0). And then the actions select Up in the Search.   In Access 97:

SendKeys Keystrokes: %hs%e%ru%n Wait: No     RunCommand Command: Find

In Access versions 2.0, 1.0, and 1.1, and version 7.0:

SendKeys Keystrokes: %hs%e%ru%n (%hs%l%u%n in version 2.0 and 1.x)         Wait: No      DoMenuItem MenuBar: Form MenuName: Edit Command: Find

