I've created a search form. It has 5 searchable fields, only the "SetRef" field below is a text field, the rest are combos. All fields unbound.
The search button I created has the following code:
but it doesn't work, when I search it tells me I have "Syntax Error (missing operator) inquery expression".
I've tried playing around with it, but I just can't get it to work. Any help is greatly appreciated.
The search button I created has the following code:
Code:
Private Sub Search_Click()
Dim SearchCriteria As String
'Set Case Status Criteria
'-------------------------
Dim StatusCriteria
If Not IsNull([CaseStatus]) Then
StatusCriteria = "(" + "[CaseComplete]=" & Me![CaseStatus] + ")" + " And "
Else
StatusCriteria = ""
End If
'Set Set Reference Search Criteria
'---------------------------
Dim SetRefCriteria
If Not IsNull([SetRef]) Then
SetRefCriteria = "(" + "[Test Set Reference]=" & Me![SetRef] + ")" + " And "
Else
SetRefCriteria = ""
End If
'Set Prepared by Search Criteria
'---------------------------
Dim PrepCriteria
If Not IsNull([Prep]) Then
PrepCriteria = "(" + "[Prepared by]=" & Me![Prep] + ")" + " And "
Else
PrepCriteria = ""
End If
'Set Case Priority Search Criteria
'---------------------------
Dim CasePriorityCriteria
If Not IsNull([CasePriority]) Then
CasePriorityCriteria = "(" + "[Priority code]=" & Me![CasePrority] + ")" + " And "
Else
CasePriorityCriteria = ""
End If
'Set Case Tester Search Criteria
'---------------------------
Dim CaseTesterCriteria
If Not IsNull([CaseTester]) Then
CaseTesterCriteria = "(" + "[Tester]=" & Me![CaseTester] + ")"
Else
CaseTesterCriteria = ""
End If
SearchCriteria = CasePriorityCriteria + StatusCriteria + SetRefCriteria + PrepCriteria + CaseTesterCriteria
DoCmd.OpenForm "Test Cases all", , , SearchCriteria
End Sub
I've tried playing around with it, but I just can't get it to work. Any help is greatly appreciated.