filter combox based on another combox issue

siamandm
BronzeLounger
Posts: 1211
Joined: 01 May 2016, 09:58

filter combox based on another combox issue

Post by siamandm »

hello All

I have two combo box the second one filtered based on the first one,

Code: Select all

[forms]![QualityTestReport]![frmTestResults]![cboTestNameID]
im using after update event on the first one to filter the second one

Code: Select all

Private Sub cboTestNameID_AfterUpdate()
Me.cboStdTestMethodID.Requery
End Sub
it works fine, but when i have a continues form, and add a new row and update the first combo box the second combo box in the first row updates and get blank as below
Screenshot 2024-04-01 110552.png
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78386
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: filter combox based on another combox issue

Post by HansV »

This is a known problem for continuous forms. When you select a test name in the second record, the Row Source of the test method combo box changes for ALL records, not just the second one. As a consequence, the test method you selected in the first record is not part of the Row Source anymore, so the combo box displays a blank.

To work around this, we can use a trick.

Make sure that the Record Source of the form includes the name of the test method.
Create a new text box on the form.
Delete its label (if it has one).
Set its Control Source to the name of the test method.
Move and resize the text box so that it exactly covers the test method combo box except for its drop-down arrow.
This text box will only be used to display the name. We don't want the user to edit the name, so set the Locked property of the text box to Yes.
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1211
Joined: 01 May 2016, 09:58

Re: filter combox based on another combox issue

Post by siamandm »

Dear Hans,

thank you very much it worked very well.

Regards