By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,171 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Combo Box

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.