473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Combo Box

Dear All,

I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.

I hope you will help me in this,

I thank you people in advance,

farhaaad

May 20 '07 #1
5 2551
On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
Dear All,

I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.

I hope you will help me in this,

I thank you people in advance,

farhaaad
Set the City combo box RowsourceType property to Table/Query.
Leave the City combo box Rowsource property blank.
Code the State Combo box AfterUpdate event:
CityCombo.RowSource = "Select TableName.[City] From TableName Where
TableName.[State] = '" & Me.StateCombo & "' Order by [City];"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 20 '07 #2
On May 20, 10:32 am, fredg <fgutk...@example.invalidwrote:
On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
Dear All,
I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.
I hope you will help me in this,
I thank you people in advance,
farhaaad

Set the City combo box RowsourceType property to Table/Query.
Leave the City combo box Rowsource property blank.

Code the State Combo box AfterUpdate event:
CityCombo.RowSource = "Select TableName.[City] From TableName Where
TableName.[State] = '" & Me.StateCombo & "' Order by [City];"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
I thank you very much for this, but still i have a problem if you can
solve it. with the same codeline it says DATA TYPE MISMATCH IN
CRITERIA EXPRESSION
here is my codeline:

City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = '" & Me.Combo0.Column(0) & "' orderby [City];"

can you tell me what is wrong with it please?
Thanks alot.

Farhaad

May 20 '07 #3
Farhaad Faaique wrote:
On May 20, 10:32 am, fredg <fgutk...@example.invalidwrote:
>>On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:

>>>Dear All,
>>>I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.
>>>I hope you will help me in this,
>>>I thank you people in advance,
>>>farhaaad

Set the City combo box RowsourceType property to Table/Query.
Leave the City combo box Rowsource property blank.

Code the State Combo box AfterUpdate event:
CityCombo.RowSource = "Select TableName.[City] From TableName Where
TableName.[State] = '" & Me.StateCombo & "' Order by [City];"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I thank you very much for this, but still i have a problem if you can
solve it. with the same codeline it says DATA TYPE MISMATCH IN
CRITERIA EXPRESSION
here is my codeline:

City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = '" & Me.Combo0.Column(0) & "' orderby [City];"

can you tell me what is wrong with it please?
Thanks alot.

Farhaad
Should orderby should be order by?
May 20 '07 #4
On 20 May 2007 04:16:55 -0700, Farhaad Faaique wrote:
On May 20, 10:32 am, fredg <fgutk...@example.invalidwrote:
>On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
>>Dear All,
>>I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.
>>I hope you will help me in this,
>>I thank you people in advance,
>>farhaaad

Set the City combo box RowsourceType property to Table/Query.
Leave the City combo box Rowsource property blank.

Code the State Combo box AfterUpdate event:
CityCombo.RowSource = "Select TableName.[City] From TableName Where
TableName.[State] = '" & Me.StateCombo & "' Order by [City];"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

I thank you very much for this, but still i have a problem if you can
solve it. with the same codeline it says DATA TYPE MISMATCH IN
CRITERIA EXPRESSION
here is my codeline:

City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = '" & Me.Combo0.Column(0) & "' orderby [City];"

can you tell me what is wrong with it please?
Thanks alot.

Farhaad
Evidently your field name is State_ID, a Number datatype, not State, a
Text datatype. And yes, it should be Order By.
Try:

City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = " & Me.Combo0.Column(0) & " order by [City];"

Note: when asking questions in the future, it's always best to give
your actual Table Field names and their datatypes. The syntax is
different for Number, Text, and Date datatypes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 20 '07 #5
On May 21, 2:10 am, fredg <fgutk...@example.invalidwrote:
On 20 May 2007 04:16:55 -0700, Farhaad Faaique wrote:


On May 20, 10:32 am, fredg <fgutk...@example.invalidwrote:
On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
>Dear All,
>I have two tables i.e States and Cities and it has a one to many
relationship as one state has many cities. Now, when i make a form and
create two combo boxes for states and cities what i want the state
combo box to do is: when a speicific state is selected in state combo
box the second combo (City) should only show the cities that bleong to
the selected State.
>I hope you will help me in this,
>I thank you people in advance,
>farhaaad
Set the City combo box RowsourceType property to Table/Query.
Leave the City combo box Rowsource property blank.
Code the State Combo box AfterUpdate event:
CityCombo.RowSource = "Select TableName.[City] From TableName Where
TableName.[State] = '" & Me.StateCombo & "' Order by [City];"
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
I thank you very much for this, but still i have a problem if you can
solve it. with the same codeline it says DATA TYPE MISMATCH IN
CRITERIA EXPRESSION
here is my codeline:
City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = '" & Me.Combo0.Column(0) & "' orderby [City];"
can you tell me what is wrong with it please?
Thanks alot.
Farhaad

Evidently your field name is State_ID, a Number datatype, not State, a
Text datatype. And yes, it should be Order By.
Try:

City.RowSource = "select Cities.[City] from Cities where Cities.
[State_ID] = " & Me.Combo0.Column(0) & " order by [City];"

Note: when asking questions in the future, it's always best to give
your actual Table Field names and their datatypes. The syntax is
different for Number, Text, and Date datatypes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -

- Show quoted text -
Thanks alot.
It worked

May 21 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
4
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of...
6
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a form with combo box field that allows the user to select from the combo box or type in the field value that may or maynot be in the combo box field. ...
2
by: Jeff Mason | last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with the combo's anchor property. I define a form which contains just a textbox and a combo box. The text box is...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
2
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.