Cascading Combo Boxes Form and Subform

Bob M

Registered User.
Local time
Yesterday, 19:07
Joined
Sep 11, 2002
Messages
42
I have two tables Suppliers with SupplierID as the primary key and another table Products with ProductID as the primary key and SupplierID as a foreign key linked to Suppliers.


I have a form with a combo box SupplierID and a subform with a ProductID combo box.

For the SupplierID combo box the rowsource is: SELECT DISTINCTROW Suppliers.* FROM Suppliers ORDER BY Suppliers.SupplierName
and it AfterUpdate event is:
Forms![Purchase Orders Subform].ProductID.Requery

For the ProductID combo box rowsource the WHERE clause is:
WHERE Products.SupplierID=Forms![Purchase Orders].SupplierID

I want the ProductsID combo to only show values based on the selection made in the SuppliersID Box.

I have followed the code examples for cascading combo boxes but I get the following error when I exit the SuppliersID combo box after selecting a value.

Microsoft Access cannot find the form 'Purchase Orders Subform' referred to in a Macro Expression or Visual Basic code.


What am I doing wrong?
 
You need to reference the MAIN FORM in your criteria and NOT just the subform..

So...

Forms![Purchase Orders Subform].ProductID.Requery

should be...

Forms![Purchase Orders]![Purchase Orders Subform].ProductID.Requery
 
Cascading Combo Boxes form and subform

Thanks for the info. I found the same thing in a Microsoft article. My syntax was off.
Thanks to all the great info I get here I'm learning a quite a lot of what I need to know.


Thanks again.


From the land of the frozen chosen.
 

Users who are viewing this thread

Back
Top Bottom