Recordset from query based on combobox

sir_aingeal

Registered User.
Local time
Today, 09:26
Joined
Nov 5, 2002
Messages
21
I am trying to create a subform based upon a recordset, that is created from a query based upon the selection in a combobox.

So that when a selection is made in the combo it runs the query based upon the selection and then populates a subform.

Never having written very much VBA I would appreciate some points in this endevour.

Thanks
 
Not much VBA needed here.

1. Set the Query's criteria to the form and control (The ComboBox). =Forms![Forms Name]![ComboBox Name]

2. Then on the Click Event of the ComboBox requery the SubForm. Me.[Sub Form's Control Name].Requery
 
Thanks but before it runs the query it has to set the table it will run the query on, as the current table(recordset), based upon the selection in the combobox.
 
I don't quite understand what you are describing. Travis described the usual way of filtering a recordset that populates the subform. How is yours different and what do you mean by
Set the table....
?
 
What I have is a number of different tables all with the same structure but different data in each. e.g. A different table for each state.

What I am trying to do is when the state is selected in the combobox, run the query on the table that matches the state selected. Then populate a form with the results of that query.

Thanks
 
This is throwing up problems with your data structure.
You do not need a different table for each state, you only need one table for the list of states and a table for the state information with a foreign key to the StateID. This is why Travis' solution is not working.

Before going any further, read some of the posts on this forum on normalisation or that are contributed by Pat Hartman, the undisputed normalisation guru.

If you normalise your data structure, the rest is easy (ahem)
 
Thanks for looking at the problem but I have now got it to work.
 

Users who are viewing this thread

Back
Top Bottom