Combo Box Row Source

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I need to set the values of a combobox, "Town" for example, to be dependent
on the value of anther combobox,"County" for example. How do I set it up so
that if under County I choose "Schoharie" the row source for Town changes to
the table with the data of Schoharie County?
Thanks!
 
Link the second combo to the first combo using the RowSource

In the second combo row source write SQL like

Select Field1, Field2 From TableName Where FieldName =
Forms![FormName]![SubFormName].Form![Combo1Name]

On the after update event of the first combo write the code
Me.Combo2Name.Requery
==================================
 
It sounds as if you have a design problem if your tables are county specific.
You should have just one table with this information. To base on combo box
on anther place something like the following in the control source of the
town combo:
=Select [MyTable].[town] from MyTable where ([MyTable].[county] =
Forms![MyForm]![Mycombo1])
Then in the afterupdate event of the county combo but the following code
Me![Mycombo2].requery

There are ways to work around having different tables, if you can not change
the design. In the afterupdate event of the county combo box
Me![MyCombo2].rowsource = "Select [town] from " & Forms![MyForm]![Mycombo1]
Me![MyCombo2].requery
 
Let me see if Understood. you have two combobox named: Town & County and you
want to Select a name in [Town] and your dropped datas in [County]will be
related to the name that you selected in first combo box.

if so you can use a statements like this in row source of County combobox.

SELECT yourtable.yourfield WHERE ((yourtable.yourfield)=Forms!yourform!Town));

maybe this help you.
 

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

Back
Top