troubleshooting Question

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

Avatar of ES-Components
ES-ComponentsFlag for United States of America asked on
Microsoft Access
11 Comments1 Solution64 ViewsLast Modified:
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?

Code#1
Private Sub CmbSearch_AfterUpdate()
If Len(Form_DetailMonth.Filter) > 0 Then
Form_DetailMonth.Filter = Form_DetailMonth.Filter & " AND " & "Expr21 = '" & Me.CmbSearch & "'"
Else
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 & "'"
Else
Form_DetailAllCustomer.Filter = "Expr21 = '" & Me.CmbSearch & "'"
End If
Form_DetailAllCustomer.FilterOn = True
End Sub


I use this button to close and reopen the form:
Code#2
Private Sub Command26_Click()
DoCmd.Close
DoCmd.OpenForm "OpenSalesOrders_Detail"
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros