combo box or list box

  • Thread starter Thread starter sweetummy
  • Start date Start date
S

sweetummy

Hi all ,
i have 2 text boxes on form.
one is for "countries" and other is for "states" ,
Which i have created my table name as "countriesAndStates"
i have given all the country names and it states side by side..
just as below..

country state
eg: USA ALASKA
USA CALIFORNIA

when the user selected INDIA IN THE COUNTRY COMBO BOX ONLY STATES of
that particular country should be displayed .
what i have to do?
 
Set up the row source for the second combobox to use the value in the first
combobox. And then in the change event of the Countries combobox, requery the
second combobox.

So your row source for the States combobox would be

SELECT State FROM CountriesAndStates WHERE Country like
Nz(Forms![NameOfTheForm]![NameOfCountryCombobox],"*")

Your code in the after update event of the CountryCombobox would be

Me.NameOfStatesCombobox.Requery.

NOTE that this does not work well in a continuous form. Since there is really
only one combobox on the continuous form - you just see multiple images of the
control. And you would need to requery the States Combobox in the current
event of the form in order to see the state values for the current record.

There are various ways to handle the situation if you are using a continuous form.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
yes its not working for in a continous form could tell me how to
implement "Lost focus" functionality for this situation...
B'cos when i select country and click on the tab immediately 2nd combo
box should be displayed the states..
 
Back
Top