Avatar of ES-Components
Flag for United States of America

asked on 

How can I use a combo selection box multiple times in a form?

I have one Combo Search box that that uses the code below (Code#1) to search 2 Subforms on a form. It works for ONE selection only.
I have to use a button to close and reopen the form in order to make another selection with the combo box. Is there something that I can add
in Code#! to allow me to make additional selections with the combo box without having to close and reopen the form with a button?

Private Sub CmbSearch_AfterUpdate()
If Len(Form_DetailMonth.Filter) > 0 Then
Form_DetailMonth.Filter = Form_DetailMonth.Filter & " AND " & "Expr21 = '" & Me.CmbSearch & "'"
Form_DetailMonth.Filter = "Expr21 = '" & Me.CmbSearch & "'"
End If
Form_DetailMonth.FilterOn = True
If Len(Form_DetailAllCustomer.Filter) > 0 Then
Form_DetailAllCustomer.Filter = Form_DetailAllCustomer.Filter & " AND " & "Expr21 = '" & Me.CmbSearch & "'"
Form_DetailAllCustomer.Filter = "Expr21 = '" & Me.CmbSearch & "'"
End If
Form_DetailAllCustomer.FilterOn = True
End Sub

I use this button to close and reopen the form:
Private Sub Command26_Click()
DoCmd.OpenForm "OpenSalesOrders_Detail"
End Sub
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon