cascading combo.

S

scubadiver

I am currently trying to create a cascading combo.

The first table is called "Dept" and has two columns: "categoryID" and "Dept".

The second table is called "Subdept" and has three columns: "categoryID",
"Dept" and "Subdept".

In the first combo box I have "dept" and the second combo box I have "dept"
and "subdept".

The first combo box is called "Dept" and the row source is:
SELECT [Dept].[Dept] FROM Dept;

The second combo box is called "Subdept" and the row source is:

SELECT [Subdept].[Subdept] FROM Subdept WHERE
((([subdept].[dept])=[Forms]![Form1]![dept]));

Two problems:

1) Regardless of which first option I pick, the list in the 2nd box remains
the same

2) Any of the options in the 2nd box can't be chosen.

ideas?

cheers in advance.
 
D

Douglas J Steele

No idea about the second problem (unless you've locked the combobox), but
for the first one, put code in the AfterUpdate event of the first combo to
update the second one:

Private Sub Dept_AfterUpdate()

Me.Subdept.Requery

End Sub
 
S

scubadiver

Thanks for that.

I sorted out the other problem. In the properties box, I had 2 bound columns
instead of 1.

Its working now.

Douglas J Steele said:
No idea about the second problem (unless you've locked the combobox), but
for the first one, put code in the AfterUpdate event of the first combo to
update the second one:

Private Sub Dept_AfterUpdate()

Me.Subdept.Requery

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


scubadiver said:
I am currently trying to create a cascading combo.

The first table is called "Dept" and has two columns: "categoryID" and "Dept".

The second table is called "Subdept" and has three columns: "categoryID",
"Dept" and "Subdept".

In the first combo box I have "dept" and the second combo box I have "dept"
and "subdept".

The first combo box is called "Dept" and the row source is:
SELECT [Dept].[Dept] FROM Dept;

The second combo box is called "Subdept" and the row source is:

SELECT [Subdept].[Subdept] FROM Subdept WHERE
((([subdept].[dept])=[Forms]![Form1]![dept]));

Two problems:

1) Regardless of which first option I pick, the list in the 2nd box remains
the same

2) Any of the options in the 2nd box can't be chosen.

ideas?

cheers in advance.
 
Top