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

Search Function

Status
Not open for further replies.

oliver10

Technical User
May 2, 2001
5
US
I have a table with patient names, Medical record#'s etc. I have created a search form that opens blank (because no patient names are allowed to show upon opening the form) but I would like to allow the user to just type the patient name or medical record# into one of these blank spaces and have the patient's name appear on the patient form lookup.

I did have a standard search menu pop up that allowed you to type in the name or number and by hitting find next it would locate the patient name etc. But a decision to type directly into the blank spaces provided for patient name and medical #'s was decided as a easier search lookup.

Thank you.
 
This is actually pretty easy to do. On the keyPress event of your lookup box you want to set the filter = to your the fieldName of your lookup box then set the filter to true. You can look this up if you want or I can give you a better example later, if you want one. I have to go to a meeting now. The hardest questions always have the easiest answers.
 
Hi,
Please give me a better example I will definitely appreciate it.

Thank you. Oliver10
 
Hi,
While he's in his meeting I'll see if I can't help.

The code should look like this:

Me.Filter = "[YourFieldNameIn the Table] = " & _
[YourFieldNameOnTheForm]
Me.FilterOn = True

For example, if your Table has a field "FName" and the Form has the field "txtFName", your code would look like this:

Me.Filter = "FName = " & txtFName
Me.FilterOn = True

This will do it for you, but it your user won't be able to go to any records that don't meet the criteria.

To take the Filter off, either press the button on the toolbar with the funnell (it should be depressed) or give them another button with this code:

Me.FilterOn = False

Hope this helps!

Kyle
 
Thank you, I will let you know how it works.
Patti
 
What Oliver10 said is what I would do as well. Thank you. The hardest questions always have the easiest answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top