Query from another form

DrMaestro

Registered User.
Local time
Today, 22:37
Joined
Feb 3, 2007
Messages
21
Hi,

I created a form (frmPatient) which contains patient ID information and demographics. A pateint can have multiple mammographies on different dates. I have a button on frmPatient to open the mammographic findings form (frmMammo) and enter mammographic findings for a certain examination date (examDate). The primary key for frmPatient is PatientID (autonumber), the primary key for frmMammo is MamID (autonumber). PatientID is foreign key for MamID. They have a one-to-many relation.

Here is what I want to achieve: On frmPatient I want to add a button and a listbox. The button will trigger a query to show the dates of prior mammographic examinations on the listbox (if they exist) for the actual patient. To create the query, I think I'll have to use PatientID, MamID and examDate. For "On_click" property of the button I'll use a "Me.listbox.rowsource=" statement followed by the query statement. The problem is that I can't formulate the query. It is important for the query to show only the examination dates of the selected patient and not all of the patients. I tried the query wizard but it shows me all of the patients with a mammography and I don't know how to restrict it for a certain patient ID. I also don't know how to activate a query by pressing a button.

Any help would be very useful. Thanks....
 
Try:

Me.listbox.rowsource= "SELECT * FROM tblExams WHERE PatientID = " & Me.txtPatientID, assuming:

- your exam records are in a table called tblExams & contains the foreign key PatientID and your main form contains a textbox called txtPatiendID.

Substitute your own table name for tblExams.
 
Hi edtab,

Thank you very much for your answer. It works very well.
 

Users who are viewing this thread

Back
Top Bottom