Hello everyone I have been trying to filter data for the "First Match" and "Second Match" that does not equal certain values so the best way I thought of doing this was to create an array of possible values for the field that you would want to filter out and then use a for loop to go through each possible value and filter the data accordingly and at the same time append the values so the previous filtered data will not be lost.
First Name Last Name First Match Second Match James Matheson 0 2 Monroe Labonson 4 3 Barack Obama 2 5 Frederick Douglas 3 4 Steve MCGowan 1 1 John Seals 15 15 Mike Omalley 14 15
Private Sub notEqual_Click()
Dim strArray(0 To 13) As String
strArray(0) = "0"
strArray(1) = "2"
strArray(2) = "3"
strArray(3) = "4"
strArray(4) = "5"
strArray(5) = "6"
strArray(6) = "7"
strArray(7) = "8"
strArray(8) = "9"
strArray(9) = "10"
strArray(10) = "11"
strArray(11) = "12"
strArray(12) = "13"
strArray(13) = "14"
For i = LBound(strArray) To UBound(strArray)
'txtF and txtL are text box values of "First Match" and "Second Match"
If txtF <> "15" And txtF <> "1" And txtL_
<> "15" And txtL <> "1" Then
Me.Filter = "First Match = """ & strArray(i) & """"
Me.Filter = Me.Filter & " AND Second Match = """ & strArray(i) & """"
End If
Next
FilterOn = True
End Sub
I get an error that says syntax error (missing operator) in query expression 'First Match0". Am I possibly appending the values the wrong way? I feel like there is something wrong with the code inside the for loop.