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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find dialog box – Find function

Status
Not open for further replies.

dezel

MIS
Dec 17, 2002
4
US
I would like to use the Find option in Access but with set criteria. When opening the find dialog box we are presented with “Find what”, “Look in”, “Match”, and with in the More button, “Search”, “Match Case”, “Search Fields as Formatted”.
How can I open the find dialog box with set criteria or is it possible to create a custom Find based on code?

Ideal scenario: Find command button placed on a form set to search one field with the possibility of the curser not in the field to be searched. A popup dialog box with one field searching a defined set of parameters (look in, match, search, match case, search fields as formatted).
 
Of course you can do it in a custom form.

You create the "search" form, and put whatever controls on it that you want.

Next, you can either type out the SQL you want to run when someone searches, or else build a query, and copy the SQL code from it.

Then in your VBA, you edit the SQL statement to base some things on variables or instances of the controls containing data on your form.

Then, for the results, you could have a subform show them on the search form or in a subform on the form on which you clicked "find", or in a new form altogether.

That's at least the basic idea, as best as I know off hand.

--

"If to err is human, then I must be some kind of human!" -Me
 

Obviously, if the code's behind a command button the field to search is not going to have focus. Here's a routine that does some of what you want. Don't remember where I got it from. The uses SendKeys, unfortunately, to set the parameters(and I don't which SendKeys would set the other parameters you want) and Screen.PreviousControl.SetFocus to set focus back in the last field the cursor was in. You'd have replace this with YourFieldToSearch.SetFocus. Hope it helps.

Invokes Find with Match Any Part of Field

Choose Options from the Tools menu.
On the Edit/Find tab, set:
Default find/replace behavior
to:
General Search

Private Sub Command70_Click()
Screen.PreviousControl.SetFocus
SendKeys "%ha%n", False
DoCmd.RunCommand acCmdFind
End Sub

Hope this helps some!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
kjv1611,
use SQL from a Query - sounds good (kinda the same as query on form)

PVH,
query on form - used it, I like but want the function of find

missinglinq,
took the words out of my mouth, I have used send keys and can setfocus, send the keys to open the find box but the checked items may or may not be checked when the box opens. So in a macro set to check the box every time only works when the box is not checked other wise the commands uncheck it :(

thank you for tips.
on with the cat skinning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top