filter results based on two combo boxes

I don't think this is a cascading combobox issue.

I need to filter my query results based on two combo boxes - I want the combo boxes to work like an AND operator, rather than just filter the results on the last combobox. I also have a tickbox that should filter on one field, and I'd like that combined into the filter somehow.

Right now, I have a combobox that lists staff - selecting it shows the results filtered by staff. Great.
I also have a combobox that lists calls assigned to a team, selecting it shows all calls for that team. Perfect.
I have a tickbox to filter only open calls (unticking it lists all calls open or otherwise). This is based on a field in the table "isClosed".

What I want is to select either combobox and have the results updated based on the value in both boxes, and include the tickbox into the equation, allowing me to chose any combination of combobox and tick status, and get the results I want.

Can someone point me in the right direction please?

Thanks in advance!
LVL 2
RossAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RossAuthor Commented:
I've found some code I can apply to my situation:
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click

Dim strSQL As String, intCounter As Integer
     'Build SQL String
For intCounter = 1 To 5

    If Me("Filter" & intCounter) <> "" Then
    
        If intCounter > 2 Then
        strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & CInt(Me("Filter" & intCounter)) & " And "
        
        Else
        
        strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
        
        End If
    
    End If

Next
     
     If strSQL <> "" Then
        'Strip Last " And "
        strSQL = Left(strSQL, (Len(strSQL) - 5))
        'Set the Filter property
        Me.Filter = strSQL
        Me.FilterOn = True
     Else
        Me.FilterOn = False
     End If

Exit_cmdFilter_Click:
    Exit Sub

Err_cmdFilter_Click:
    Resume Exit_cmdFilter_Click
    
End Sub

Open in new window


I've named my combo boxes "filter1" and "filter2".

Just struggling still. I'll keep you updated.
0
RossAuthor Commented:
Ok - I now have this working with my two combo boxes based on using and adapting the above code. But I'm stumped when trying to intruduce the checkbox into the search string. Any pointers please?
0
RossAuthor Commented:
Ok sorted this myself.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.