A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

combo box or list box



 
 
Thread Tools Display Modes
  #1  
Old September 13th, 2009, 04:12 PM posted to microsoft.public.access.reports
sweetummy
external usenet poster
 
Posts: 20
Default combo box or list box

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?
  #2  
Old September 13th, 2009, 04:29 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default combo box or list box

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

sweetummy wrote:
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?

  #3  
Old September 14th, 2009, 02:39 AM posted to microsoft.public.access.reports
sweetummy
external usenet poster
 
Posts: 20
Default combo box or list box

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..
  #4  
Old September 14th, 2009, 02:39 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default combo box or list box

Check out Doug Steele's February 2006 example database and article.

http://www.accessmvp.com/DJSteele/SmartAccess.html

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

sweetummy wrote:
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..

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.