Error in Combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an order detail table....when you select the catagory combo box the product combo box should update with the relevant products in that catagory.I have used the following code in the afterupdate even

Private Sub cbocatagory_AfterUpdate(
Me!cboProduct.RowSource = "SELECT [productID],[product] FROM [products] WHERE [CatagoryID]=" & Me!cboCatagory & " ORDER BY [product];
End Su

Seems to work fine however as I move through the form filling it in some of the items from the product combo box disappear from view................any ideas for this novice in access
 
Hi Michael,

I take it the order details are displayed in a continuous subform (or
form). In continuous view it looks as if there's a separate set of
controls on each record you see, but Access is faking it, and all the
product combo boxes in sight are in effect copies of the same one and
have the same properties (except, in the case of bound fields, for the
Value property).

So the RowSource for all of them is whatever RowSource was set by the
most recent cboCategory_AfterUpdate() event. Suppose that in one order
detail the productid is 456. If the recordset returned by the most
recent RowSource includes (456, "Widget A"), then the combo will display
"Widget A". If it doesn't, the combo will be blank. And so on.

One way round this would be to reset the RowSource to a query that
returns all productids and products after the user has selected the
product from the filtered list - probably in cboProduct_AfterUpdate().


I have an order detail table....when you select the catagory combo box the product combo box should update with the relevant products in that catagory.I have used the following code in the afterupdate event

Private Sub cbocatagory_AfterUpdate()
Me!cboProduct.RowSource = "SELECT [productID],[product] FROM [products] WHERE [CatagoryID]=" & Me!cboCatagory & " ORDER BY [product];"
End Sub


Seems to work fine however as I move through the form filling it in some of the items from the product combo box disappear from view................any ideas for this novice in access
 
Michael,

You've already got this in cboCategory_AfterUpdate()
Me!cboProduct.RowSource = "SELECT [productID],
[product] FROM [products] WHERE [CatagoryID]=" &
Me!cboCatagory & " ORDER BY [product];"


I think that all you need is this

Me!cboProduct.RowSource = "SELECT productID, product FROM [products]
ORDER BY product;"

in cboProduct_AfterUpdate()
 
Back
Top