I have 2 fields that I would like to use to have the records displayed to only be those that match the criteria. Individually the filter works but when I try to combine them I get a Syntax error for a missing operator.
VBA Code:
Private Sub ApplyFilter()
'Entire Filter String
Dim FltCriteria As String
'Individual Section Strings
Dim FilterNo1Check As String
Dim FilterNo2Check As String
Forms!frmPhoneListing.FilterOn = False
FltCriteria = ""
If Me!FilterNo1 <> "" Then
FilterNo1Check = Me!FilterNo1
FltCriteria = " [PhContactMain]LIKE " & "'" & "*" & FilterNo1Check & "*" & "'"
End If
If Me!FilterNo2 <> "" Then
FilterNo2Check = Me!FilterNo2
If FltCriteria = "" Then
FltCriteria = " [PhContactSub]LIKE " & "'" & "*" & FilterNo2Check & "*" & "'"
Else
FltCriteria = FltCriteria & " [PhContactSub]LIKE " & "'" & "*" & FilterNo2Check & "*" & "'"
End If
End If
Forms!frmPhoneListing.Filter = FltCriteria
Forms!frmPhoneListing.FilterOn = True
End Sub