Criteria Of A Query. Can it be automised?

normski

Registered User.
Local time
Today, 11:46
Joined
Dec 8, 2006
Messages
20
Hi, I was just wondering if the criteria in a query or a search/filter can automatically put the contents of whatever is in a textbox (text) as the filter and so it will display only results with whatever is in the textbox, in the record.

I have a doctors patient surgery and In the "Patient Records" Form I have all of their information etc. I can click through the records and different information coms up for each person as I want it to, including their current medication. I also have a form called "Drug reference" and That is the same thing except with drugs. So I can click through the records and each drug will come up with its own information.

As I stated above. Id like to be able to click on the "current medication" box in my "Patient Records" form, of which there are 7 and when I click on the box it loads up the Drug reference Form at the correct record. I.e so if a patient is on "benzol" and I click on the text box with that information in it. The "Drug Reference" form will load up at the correct record- Benzol.

Please Please help me in any way. I feel I might have to do it in a query, and I don't want to use a combo box for each medication that they are on since I will then have 7 combo boxes on my form and when I would click on them they would have just 1 record in, which is a bit silly.
 
So if the user click the medication text box you want another form to open up displaying the information for the medication listed in the textbox? I would use the On_Click event of the text box to open the form with Docmd.openform and then filter the form for the medication.
 
Yep that is what i want, IM just not too good with the filtering :S Can you possibly help me through it?
 
Is this drug form used just for this purpose? If so in the On_Open event of the form put

me.filter="[FieldName]='" & forms![FormName]![TextBoxName]

FieldName=Name of the field to apply the filter to

FormName=Name of form with drug textbox on it

TextboxName=Name of textbox for the drug field
 
I'm also using it to just look up drug information anyway, but I can just copy it for that since it isn't linked to anything. Im assuming I put the names of my form etc in where it says [formname]?

I tried it and it comes up with an error saying cannot find the macro "me". And I haven't made one called "me", so should I make one,and what should I put in it?
 
Last edited:
Did you put the code on the Drugs form Open Event? Me refers to the form the code is written on. It sounds like you may have put this code in a seperate module.
 
I just used the simple one that you suggested earlier and I think (I can't quite remember) i just didn't have the form open when I ran the macro, so it couldn't find it and so When I had the form open and ran the macro it worked fine! Scuppered by a tiny detail!!
 

Users who are viewing this thread

Back
Top Bottom