Form/Subform - Filter

T

TriX

Hello all,
I'm in the process of creating an inventory database and have
encountered a significant road block.
I have a form/subform problem where I have a combo box called
"Supplier" on the main form, and I have products (combobox) in the
subform.
I'm trying to get ONLY the products of the selected supplier (in the
main form) to show in the combobox of products in the subform.
I was able to accomplish this (update products based on supplier),
within the same form, but cannot accomplish this when dealing with a
form/subform.
I'm not too familiar with VB or SQL code, so please help solve my
problem step by step !!! :)
Thanks so much.
 
T

tina

presumably your supplier table is related to your products table with a
primary/foreign key pair, such as

tblSuppliers
SupplierID (primary key)

tblProducts
ProductID (primary key)
SupplierID (foreign key from tblSuppliers)

and, again presumably, the relationship is

tblSuppliers.SupplierID 1:n tblProducts.SupplierID

if the above is how your tables are set up, then in the subform, set the
combo box's RowSource property to something like

SELECT ProductID FROM tblProducts WHERE SupplierID =
Forms!MainFormName!SupplierID

in the main form, requery the subform combo box on the main form's Current
event, and also on the AfterUpdate event of the SupplierID field, as

Me!SubformControlName.Form!ComboBoxName.Requery

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top