I'm getting a run-time error on this code and I think I'm missing a bracket. Can someone please help me?
Thank you!!
Thank you!!
Code:
Sub Search()
Dim tempCriteriaForReport As TempVar
Dim strSearch, strCriteria, strGender, strColour As String
Dim task As String
Dim varItem As Variant
If Not IsNull(Me.txtColour) Then
strColour = "([colour] like ""*" & Me.txtColour & "*"") or ([notes] like ""*" & Me.txtColour & "*"")"
strCriteria = strColour
End If
For Each varItem In Me!ListGender.ItemsSelected
strGender = strGender & "[GenderID] = " & Me!ListGender.ItemData(varItem) & Chr(34) & "Or"
Next varItem
If Len(strGender) > 0 Then
strGender = Left(strGender, Len(strGender) - 2)
strCriteria = strCriteria & " And (" & strGender & ")"
End If
task = "select * from [qrywaitinglist] where (" & strCriteria & ")"
Me.FilterOn = True
DoCmd.ApplyFilter task
TempVars!tempCriteriaForReport = task '' set temp string criteria for report preview
Me.txtTotal = FindRecordCount(task)
End Sub