3 synchronized combo boxes

C

Christine

I have 3 combo boxes on a form that are synchronized to
display results depending on the user's selection.

* cboCategory

* cboProduct - displays products for the
category selected in cboCategory

* cboBoard - displays boards for the product
selected in cboProduct

The first two combos work well, but cboBoard always
displays info from the last entry in cboProduct.

Here's the code:
* cboCategory row source = SELECT Categories.CategoryID,
Categories.CategoryName FROM Categories ORDER BY
Categories.CategoryName;

After update event = Me!cboProduct = Null Me!
cboProduct.Requery

* cboProducts row source = SELECT Products.ProductID,
Products.ProductName FROM Products WHERE
(((Products.CategoryID) Like forms!frmTwoCboOpenForm!
cboCategory)) ORDER BY Products.ProductName;

After update event = Me.cboBoard = Null
Me.cboBoard.Requery

* cboBoards row source = SELECT DISTINCT Boards.ProductID,
Boards.BoardName FROM Boards WHERE (((Boards.ProductID)
Like forms!frmTwoCboOpenForm!cboProduct)) ORDER BY
Boards.BoardName;

The commands "= Null" and "Requery" work just fine for
setting and resetting for cboCategory and cboProduct, but
I'm dumbfounded as to whey they don't clear cboBoard
results when cboCategory or cboProducts change.

Any help on offer will be very welcome!
Christine
 
M

Marshall Barton

Christine said:
I have 3 combo boxes on a form that are synchronized to
display results depending on the user's selection.

* cboCategory

* cboProduct - displays products for the
category selected in cboCategory

* cboBoard - displays boards for the product
selected in cboProduct

The first two combos work well, but cboBoard always
displays info from the last entry in cboProduct.

Here's the code:
* cboCategory row source = SELECT Categories.CategoryID,
Categories.CategoryName FROM Categories ORDER BY
Categories.CategoryName;

After update event = Me!cboProduct = Null Me!
cboProduct.Requery

* cboProducts row source = SELECT Products.ProductID,
Products.ProductName FROM Products WHERE
(((Products.CategoryID) Like forms!frmTwoCboOpenForm!
cboCategory)) ORDER BY Products.ProductName;

After update event = Me.cboBoard = Null
Me.cboBoard.Requery

* cboBoards row source = SELECT DISTINCT Boards.ProductID,
Boards.BoardName FROM Boards WHERE (((Boards.ProductID)
Like forms!frmTwoCboOpenForm!cboProduct)) ORDER BY
Boards.BoardName;

The commands "= Null" and "Requery" work just fine for
setting and resetting for cboCategory and cboProduct, but
I'm dumbfounded as to whey they don't clear cboBoard
results when cboCategory or cboProducts change.


You should also set cboBoard to Null in the cboCategory
AfterUpdate event.

Note that your use of the Like operator is at best unusual
and may be fairly inefficient. If you're not using wildcard
characters for partial matched, you should just use the =
operator instead.
 
C

Christine

Thank you, Marsh. I found that, in addition to your
recommendation, I also had to add "Me.cboBoard.Requery" to
cboCategory's after update event.

Also, thanks for pointing out the "Like" vs. "=" syntax on
my query. What was I thinking!!

Christine
 

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

Similar Threads


Top