Synchronizing State and County Combo Boxes

M

missamay

I have cmbState and cmbCounty on a form that corresponds to a table. I
want the Counties shown in the cmbCounty to be limited by the State
chosen in cmbState. I have tried the code from the Access sample forms
and The Access Web with no success. I am pulling data from one table
and a query for the combo boxes. qryState contains a list of the 50
states and tblCounty has all the counties in the US with the
corresponding state. I am able to display the States in the combo box
by using the query as the RecordSource, but am unable to get the
Counties to display based on the state. I did not get errors when I
tried the code from the Access sample forms and The Access Web, but the
cmbCounty box remained empty.

Any help or suggestions would be greatly appreciated. Thanks!

Melissa
 
D

Douglas J Steele

What's the code that you're trying to use?

In general, you'd put code in the AfterUpdate event of cmbState to reset the
row source for cmbCounty, along the lines of:

Private Sub cmbState_AfterUpdate()

Me.cmbCounty.RowSource = _
"SELECT CountyName " & _
"FROM tblCounty " & _
"WHERE StateName = '" & Me.cmbState & "'"

End Sub
 

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