Combo Box


G

Guest

I would like to use a chosen value from one combo box as criteria to a form
that will be used to retrieve values for another combo box.
For example, in a given form one combo box displays the list of customers.
Based on chosen value from this combo box, I would like to display in another
combo box the list of the products that are belongs to the chosen customer.
Your help is appreciated.

Joseph
 
Ad

Advertisements

G

Guest

Hi Joseph,

In the after update event of the 1st combobox have something along the lines
of;

Me.cboProducts.RowSource = "SELECT * FROM tblProducts WHERE CustomerID = " &
Me.cboCustomer.Column(0) & ""

obviously change control, field and table names as required, and make sure
the column number corresponds to the column containing CustomerID (1st column
is 0).

hope that helps,

TonyT..
 
F

fredg

I would like to use a chosen value from one combo box as criteria to a form
that will be used to retrieve values for another combo box.
For example, in a given form one combo box displays the list of customers.
Based on chosen value from this combo box, I would like to display in another
combo box the list of the products that are belongs to the chosen customer.
Your help is appreciated.

Joseph

Leave the 2nd combo box rowsource property blank.

There may be more than one customer with the same name but the
CustomerID field should be unique.
In Combo1 make the [CustomerID] field as the bound column.
The CustomerName field should be displayed as the second column.

Code the First Combo Box AfterUpdate property:

Me![Combo2].RowSource = "Select TableName.[Product] from TableName
Where TableName.[CustomerID] = " & Me![Combo1] & "Order By [Product];"

The above assumes [CustomerID] is a Number datatype.
If [CustomerID] is Text datatype, then use:

Where TableName.[CustomerID] = '" & Me![Combo1] & "' Order By
[Product];"
 
Ad

Advertisements


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