Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Defaults for Find and Replace Dialog Box

Status
Not open for further replies.

muriel

Technical User
Feb 22, 2002
52
US
Hello. I created a "Find" command button that opens the Find and Replace dialog box. I've been working on a way to change the defaults for the Find and Replace Dialog Box. I found an article from Microsoft's support website, but I'm still confused. It says to "start the Find and Replace dialog box with the RunCommand and use the SendKeys action to select alternate settings." It gives the macro code and says it can be assigned to a command button. I tried this, but the command button already has code behind it, and when I use the macro code alone, I get an error message saying that there's no search function. My main question is: do I use the macro code alone or add it to the VB code or do something different? I'm pretty new to coding, so any help is appreciated. Thanks much!!!
 
I'm trying to accomplish the same thing but haven't been able to find any articles on Microsoft's website. If you give me the article number, I'll take a look at it and see if I can make more sense out of it.
 
Thanks for your response. The article is: "ACC2000: How to Set Defaults for the Find and Replace Dialog Box (Q208923)". I know this will make me sound even more like a novice, but I don't know how to initiate the RunCommand.
I've been warned to stay away from macros, so I'm not sure the best way to proceed here. I'm guessing there's a smarter way to change the defaults in the VB code. that's what I'm trying to figure out. Thanks!
 
This article is how we both would get the job done. It does, however, require that you make a macro. That's not as hard or complex as it may seem, however. Let me see if I can help you out here:

* From the database window, click MACRO
* In the top action, select SENDKEYS from the dropdown
* Under KEYSTOKES below, enter your choices, as per the article. For example, %ha indicates changing it from the default from ENTIRE FIELD to ANY PART OF FIELD. I don't know your requirements to give you an exact syntax (plus I just looked at the article myself)
* Leave WAIT as NO
* In the second action, select RUNCOMMAND from the dropdown
* Under COMMAND below, select FIND from the dropdown
* Save that macro as macCUSTOMFIND and exit back to the database window
* Open your form in DESIGN VIEW and create a new command button from the menu bar
* Choose MISCELLANEOUS and RUN MACRO
* Choose macCUSTOMFIND
* Finish out the command button wizard as you like

You're done! At least I hope you are, since the machine I'm on right now doesn't have Access installed, so I'm doing this from memory. Hope this helps.
 
Yes!!! It finally makes sense. I made a mistake in the command button when I tried it, and that's why it wouldn't work for me. I followed your instructions and got an error message, so I went to the properties of the command button and had to select "macCUSTOMFIND" in the OnClick box. Now it works fine.

My one remaining question: How do I set the default to search the entire form but not gray it out? I have users who may want to search one field.

Thanks for your help - I really appreciate it!!!!!!!!
 
Quick answer, I don't know :-(. Whenever I make search buttons, it NEVER defaults to the entire form. I usually do the following:

1. Set the tab order of the form to start with the most common search field. In this way, the Find should default to that field when opened.
2. Use the command button wizard to make a standard FIND RECORD button (binoculars).
3. I put a note in the form that says 'To search by a particular field, click inside of it and then click the search button'. That allows them to shift the focus as needed without dealing with the search parameters later.

As an alternative, you could just make a full search FORM, which allows them to choose a field, enter their search data and then click a button that executes a macro using the 'FindRecord Action' to perform the search. That's a whole new thing from just having the Find window open, so I don't know if you want to get that fancy. I've found my method above to be good enough for the masses.

Sorry I couldn't be of more help.
 
All good suggestions. I'm sure one method will work for me. You were of great help - I really appreciate it!!!
 
I have read your post here and set the defaults according to the KB article (208923), etc. This relates to Access2000 and I am running Access97. There is another KB article(120912) for Acc97 - but only half of the article is there (it's very weird). I guess the Find box's are slightly different between versions. Here's my problem:

When the Find box comes up, it greys out the two toggle options 1) Search Fields as Formatted, 2) Search Only Current Field.

I want mine to default to "Search Only Current Field".

Does anyone know how to do this?

Thanks very much.
Sherry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top