junaid bashir
junaid bashir

Reputation: 17

How to create dynamic cascading combo boxes in ms access

So the problem is that i am having two combo boxes in ms access subform. First is ProductID and Second is BatchID. I want to filter the BatchID for the ProductID I select.

I have placed the following code to filter the BatchID

Private Sub SetReSrc()
    Me.cbo_BatchID.RowSource = "qry_BatchID"
End Sub

Private Sub cbo_ProductID_AfterUpdate()
    SetReSrc
End Sub

For the first record it works fine. But as I enter the Product in the next record it removes the previous BatchIDs. It makes sense that it is updating the BatchID to the current selected ProductID but i want to keep the earlier ones and update only the last one.

How can I can do this.

Thanks in advance.

Upvotes: 0

Views: 446

Answers (1)

Sola Oshinowo
Sola Oshinowo

Reputation: 619

"For the first record it works fine. But as I enter the Product in the next record it removes the previous BatchIDs. It makes sense that it is updating the BatchID to the current selected ProductID but i want to keep the earlier ones and update only the last one."

If the batchids is a tied to a field as the control source, then MS Access is already doing what you want, by keeping/storing all previous values of the batchid to each record.

Ensure you are not using an unbound form control for the batchid.

Upvotes: 0

Related Questions