combo boxes

L

Lauren B

I need to have one combo box that contains a list of all state abbreviations
as a value list--when the user selects a state, I want the next combo box to
contain only the counties within that state. I have a table with states for
the first column and counties as the second column. What is the best way to
do this?

Thanks for any assistance.

LB
 
F

fredg

I need to have one combo box that contains a list of all state abbreviations
as a value list--when the user selects a state, I want the next combo box to
contain only the counties within that state. I have a table with states for
the first column and counties as the second column. What is the best way to
do this?

Thanks for any assistance.

LB

State abbreviations as a Value List? Why?
You already have a table with all the state names and their counties,
right?

Set the RowSourceType of the first combo box (cboStates) to
Table/Query.
Set it's Rowsource to:
Select Distinct tblCounties.State from tblCounties Order By
tblCounties.State;

Leave the Rowsource of the Counties combo box (cboCounties) blank.
Code the AfterUpdate event of the cboStates combo box:

cboCounties.Rowsource = "Select tblCounties.County from tblCounties
Where tblCounties.State = '" & cboStates & "' Order By County;"
 

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

Similar Threads


Top