In a form, how can I populate a Combo Box from a selection from a.

G

Guest

I am trying to setup a form contains two Combo Boxes. The first Combo is
populated with field names the table. My question is how can I populate the
second Combo Box with the values from those specific fields? For example, the
table is setup in Districts (think City Zoning or Water Pumping). I have six
districts, and each district has anywhere between 14 to 15 records, or book
listings. Want I'm loooking to do is have the user first choose which
district they would like (District 1, District 2, and so on). After the user
selects the district, I want the second Combo Box to be populated with the
values in that specific field. So if the user chooses "District 1" for the
first combo, then I want the second combo to list the values that coincide
(1A, 1B, 1C, and so on.) Same idea for the rest of the districts, District 2
with books 2A, 2B, 2C....Please help me out. I would greatly appreciate it.
 
W

Wayne Morgan

So, the field [District 1] contains the values 1A, 1B, etc.

In the AfterUpdate event of the first combo box, set the Row Source of the
second combo box.

Me.cbo2ndCombo.RowSource = "SELECT [" & Me.cbo1stCombo & "] FROM
tblTableName ORDER BY [" & Me.cbo1stCombo & "]"

This will concatenate in the value of the first combo box into the SQL
string. If the first combo contains "District 1", this would give:

SELECT [District 1] FROM tblTableName ORDER BY [District 1]

This assumes that the first combo is a single column combo box or that
"District 1" is in the Bound Column. If not, you will need to adjust this to
get the value from the appropriate column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top