Use a dropdown box to display different queries? (1 Viewer)

Db-why-not

Registered User.
Local time
Today, 15:23
Joined
Sep 17, 2019
Messages
159
I want to be able to have a main form with a dropdown list Combo box. Then a subform container on the same form.
I want the dropdown box to have selection where it shows all patients. Then selection for all patients with specific conditions, pneumothorax, pleural effusion. Then a selection for patients withdrawn.
Whenever you select the different drop down selection I want it to display the correct query subform below. With only the patients with that specific criteria.
I have the different queries saved that I want displayed and I created datasheet forms with this data. I Have all_enrolled form, pneumothorax_form, pleural_effusion_form, withdrawn_form.

Is there a way to get each of these forms to display depending on which selection is clicked on from the drop down list.

Or is there a better way to filter which patients are show by different criteria using a dropdown list.

I already know how to use a dropdown list to select 1 specific patient to show on the form. But I want a list of patients to be displayed with different criteria.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:23
Joined
Oct 29, 2018
Messages
21,469
Hi. You should check out the available demos on "search forms" to get an idea how to do something like that.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:23
Joined
Aug 30, 2003
Messages
36,125
Are the different queries/forms the same except for criteria? If so, that's a common mistake. You should have a single query/form and filter it appropriately. Methods include changing the recordsource property of the subform and setting its filter property.
 

Db-why-not

Registered User.
Local time
Today, 15:23
Joined
Sep 17, 2019
Messages
159
All of my forms could be the same form just with different criteria from different fields.

I just want different lists of patients to show up depending on criteria in different fields.

For all patients there would be no exclusion criteria. For withdrawn patients. Status field = "withdraw"
For list with patients with pneumothorax condition, the pneumothorax field is checkbox = yes

How do I code the dropdown list to input the specific criteria into the query and only display the patient list I want on the form?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:23
Joined
Aug 30, 2003
Messages
36,125
I'd leave the query without criteria. In the after update event of the combo you set one of the properties I mentioned based upon the selection. Along the lines of:

Me.SubformControlName.Form.RecordSource = "SELECT * FROM QueryName WHERE " & YourCriteriaHere

or

Me.SubformControlName.Form.Filter = YourCriteriaHere
Me.SubformControlName.Form.FilterOn = True

You would build the appropriate criteria based on the combo. You could also create the combo rowsource in such a way that the criteria was in a hidden column and you could just grab it from there.
 

Users who are viewing this thread

Top Bottom