Filter Combo Box Options based on other Combo Box Selection

P

PVANS

Good morning,

I really hope someone can help me with this, I am very new to Access

I have a form a "Trade" form where the user using the database selects a
client using a combo box (cboClient) [the available clients are populated in
a table called tbl_Client],

The next thing the user needs to is select a product using a combo box ,
however only certain products are available to certain clients (based on the
table: tblCommission), therefore, I am trying to limit the visible options in
the products combo box to just such products.

I know that I need to therefore use some code in the afterupdate event of
the cboClient, but have so far been unable to find any method of doing so.

Please help, I would really be very grateful.

Further info that could be needed:
Client Field title: Client_Surname (is the primary key in tbl_Clients; is
also of course in the tblCommission)
Product Field title: Product_Code

Thank you in advance, if you need any further info from me in order to
assist, please ask and I will reply ASAP
 
M

Marshall Barton

PVANS said:
I have a form a "Trade" form where the user using the database selects a
client using a combo box (cboClient) [the available clients are populated in
a table called tbl_Client],

The next thing the user needs to is select a product using a combo box ,
however only certain products are available to certain clients (based on the
table: tblCommission), therefore, I am trying to limit the visible options in
the products combo box to just such products.

I know that I need to therefore use some code in the afterupdate event of
the cboClient, but have so far been unable to find any method of doing so.

Please help, I would really be very grateful.

Further info that could be needed:
Client Field title: Client_Surname (is the primary key in tbl_Clients; is
also of course in the tblCommission)
Product Field title: Product_Code

A common way to do that is to create a query with a criteria
on the products for that client. Something like:

SELECT Product_Code, ProductName
FROM Products
WHERE Client_Surname = Forms!yourform.clientcombobox

Then set the products combo box's RowSource to the query.

With that in place, add some code to client combo box's
AfterUpdate event procedure:

If IsNull(Me.clientcombobox) Then
Me.productcombobox = Null
Else
Me.productcombobox.Requery
End If

You will probably want to add the same lines of code to the
form's Current event procedure.
 

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