Cascading combo boxes in a subform

  • Thread starter Thread starter Names
  • Start date Start date
N

Names

Hi,

I have 2 combo boxes (bound), where the content of the second one depends on
what is chosen from the first. I did this by following this page:
http://office.microsoft.com/en-us/access/HA011730581033.aspx

It works in a form by itself, but when I insert it as a subform into another
form it doesn't work. When a selection is made from the first combo box, a
pop-up appears instructing me to "Enter parameter value". When I click
"cancel", the second combo box is blank. Any help would be greatly
appreciated..

Thanks in advance!
 
Hi

Say you have a main form and a subform.

Open the main form in design view
Select the subform
Select the secon combo
Right click
Open properties box
Select Data column
Row Source Type = Table/Query
Select Row Source
Click build option (...)
Creat a new query (use the wizard if you want)

Say you have in the first combo
ID - 1stName - 2ndName

You need to put
Forms![MainFormName]![SubformName].Form![ID]

In the criteria row of the new combo (in the linking ID field)

Save the new query.

It should work now

The other option is to use a little bit of code like this

Private Sub 1stCombo_AfterUpdate()
Me.2ndCombo.RowSource = "SELECT TableName.ID, TabelName.AnotherField,
TableName.SomeField FROM TableName WHERE ID = 1stCombo"
End Sub

This assumes that you have the ID field in both combos and that the ID is
the bound field of the 1st combo
 
Wow. That was really fast. Thank you thank you! I'll try that.

Wayne-I-M said:
Hi

Say you have a main form and a subform.

Open the main form in design view
Select the subform
Select the secon combo
Right click
Open properties box
Select Data column
Row Source Type = Table/Query
Select Row Source
Click build option (...)
Creat a new query (use the wizard if you want)

Say you have in the first combo
ID - 1stName - 2ndName

You need to put
Forms![MainFormName]![SubformName].Form![ID]

In the criteria row of the new combo (in the linking ID field)

Save the new query.

It should work now

The other option is to use a little bit of code like this

Private Sub 1stCombo_AfterUpdate()
Me.2ndCombo.RowSource = "SELECT TableName.ID, TabelName.AnotherField,
TableName.SomeField FROM TableName WHERE ID = 1stCombo"
End Sub

This assumes that you have the ID field in both combos and that the ID is
the bound field of the 1st combo







--
Wayne
Manchester, England.



Names said:
Hi,

I have 2 combo boxes (bound), where the content of the second one depends on
what is chosen from the first. I did this by following this page:
http://office.microsoft.com/en-us/access/HA011730581033.aspx

It works in a form by itself, but when I insert it as a subform into another
form it doesn't work. When a selection is made from the first combo box, a
pop-up appears instructing me to "Enter parameter value". When I click
"cancel", the second combo box is blank. Any help would be greatly
appreciated..

Thanks in advance!
 
Just to be clear, it's

Forms![MainFormName]![SubformControlName].Form![ID]

The name of the subform control on the parent form can be different than the
name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wayne-I-M said:
Hi

Say you have a main form and a subform.

Open the main form in design view
Select the subform
Select the secon combo
Right click
Open properties box
Select Data column
Row Source Type = Table/Query
Select Row Source
Click build option (...)
Creat a new query (use the wizard if you want)

Say you have in the first combo
ID - 1stName - 2ndName

You need to put
Forms![MainFormName]![SubformName].Form![ID]

In the criteria row of the new combo (in the linking ID field)

Save the new query.

It should work now

The other option is to use a little bit of code like this

Private Sub 1stCombo_AfterUpdate()
Me.2ndCombo.RowSource = "SELECT TableName.ID, TabelName.AnotherField,
TableName.SomeField FROM TableName WHERE ID = 1stCombo"
End Sub

This assumes that you have the ID field in both combos and that the ID is
the bound field of the 1st combo







--
Wayne
Manchester, England.



Names said:
Hi,

I have 2 combo boxes (bound), where the content of the second one depends
on
what is chosen from the first. I did this by following this page:
http://office.microsoft.com/en-us/access/HA011730581033.aspx

It works in a form by itself, but when I insert it as a subform into
another
form it doesn't work. When a selection is made from the first combo box,
a
pop-up appears instructing me to "Enter parameter value". When I click
"cancel", the second combo box is blank. Any help would be greatly
appreciated..

Thanks in advance!
 
Hi Douglas

I know what you mean (as do many others here) but I think that could be a
little confusing for anyone asking for the basics of casscadeing combos


--
Wayne
Manchester, England.



Douglas J. Steele said:
Just to be clear, it's

Forms![MainFormName]![SubformControlName].Form![ID]

The name of the subform control on the parent form can be different than the
name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wayne-I-M said:
Hi

Say you have a main form and a subform.

Open the main form in design view
Select the subform
Select the secon combo
Right click
Open properties box
Select Data column
Row Source Type = Table/Query
Select Row Source
Click build option (...)
Creat a new query (use the wizard if you want)

Say you have in the first combo
ID - 1stName - 2ndName

You need to put
Forms![MainFormName]![SubformName].Form![ID]

In the criteria row of the new combo (in the linking ID field)

Save the new query.

It should work now

The other option is to use a little bit of code like this

Private Sub 1stCombo_AfterUpdate()
Me.2ndCombo.RowSource = "SELECT TableName.ID, TabelName.AnotherField,
TableName.SomeField FROM TableName WHERE ID = 1stCombo"
End Sub

This assumes that you have the ID field in both combos and that the ID is
the bound field of the 1st combo







--
Wayne
Manchester, England.



Names said:
Hi,

I have 2 combo boxes (bound), where the content of the second one depends
on
what is chosen from the first. I did this by following this page:
http://office.microsoft.com/en-us/access/HA011730581033.aspx

It works in a form by itself, but when I insert it as a subform into
another
form it doesn't work. When a selection is made from the first combo box,
a
pop-up appears instructing me to "Enter parameter value". When I click
"cancel", the second combo box is blank. Any help would be greatly
appreciated..

Thanks in advance!
 
Hi Wayne and Douglas,

Many thanks! The form is working now. And I'd given the subform control and
the subform the same name, so that was ok, and I appreciate you all taking
that into consideration..

Thanks again!

Wayne-I-M said:
Hi Douglas

I know what you mean (as do many others here) but I think that could be a
little confusing for anyone asking for the basics of casscadeing combos


--
Wayne
Manchester, England.



Douglas J. Steele said:
Just to be clear, it's

Forms![MainFormName]![SubformControlName].Form![ID]

The name of the subform control on the parent form can be different than the
name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wayne-I-M said:
Hi

Say you have a main form and a subform.

Open the main form in design view
Select the subform
Select the secon combo
Right click
Open properties box
Select Data column
Row Source Type = Table/Query
Select Row Source
Click build option (...)
Creat a new query (use the wizard if you want)

Say you have in the first combo
ID - 1stName - 2ndName

You need to put
Forms![MainFormName]![SubformName].Form![ID]

In the criteria row of the new combo (in the linking ID field)

Save the new query.

It should work now

The other option is to use a little bit of code like this

Private Sub 1stCombo_AfterUpdate()
Me.2ndCombo.RowSource = "SELECT TableName.ID, TabelName.AnotherField,
TableName.SomeField FROM TableName WHERE ID = 1stCombo"
End Sub

This assumes that you have the ID field in both combos and that the ID is
the bound field of the 1st combo







--
Wayne
Manchester, England.



:

Hi,

I have 2 combo boxes (bound), where the content of the second one depends
on
what is chosen from the first. I did this by following this page:
http://office.microsoft.com/en-us/access/HA011730581033.aspx

It works in a form by itself, but when I insert it as a subform into
another
form it doesn't work. When a selection is made from the first combo box,
a
pop-up appears instructing me to "Enter parameter value". When I click
"cancel", the second combo box is blank. Any help would be greatly
appreciated..

Thanks in advance!
 
Back
Top