troubleshooting Question

Creating multiple form controls to filter records in a subform...

Avatar of KP_SoCal
KP_SoCalFlag for United States of America asked on
DatabasesMicrosoft AccessVBA
10 Comments4 Solutions62 ViewsLast Modified:
For simplicity's sake, in my Access 2010 database form that contains a subform, let's say I have three check box controls (I actually have much more than three) that I'm using to filter records in an embedded subform.

As you can see from my code below, when Me.chkBoxFilter1 is checked, only records for fldFilter1= True are displayed. When unchecked, all records are displayed.

If IsNull(Me.chkBoxFilter1) Then
   Me.subformColorSurrogation.Form.Filter = ""
   Me.subformColorSurrogation.Form.FilterOn = False

  Me.subformColorSurrogation.Form.Filter = "[fldFilter1]=" & Me.chkBoxFilter1
  Me.subformColorSurrogation.Form.FilterOn = True
End If

Open in new window

I'm looking for a way I can add or remove other filters through the use of my other check boxes. I know I could accomplish this through multiple ELSEIF statements, but is there a way, for instance, when clicking M.chkBoxFilter2 to TRUE, to ONLY pull TRUE records for fldFilter2 without unfiltering the restrictions placed by my other checkboxes?

I hope this makes sense. I really appreciate any insight into this.
Mark Edwards
Chief Technology Officer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 10 Comments.
Start Free Trial
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 4 Answers and 10 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