In a copy of your dB, add the blue code or paste in the entire search code.
Is this close?
Code:
Private Sub cmdSearch_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.txtSearchName) Then
strWhere = strWhere & "([Name of relevant person] Like ""*" & Me.txtSearchName & "*"") AND "
End If
If Not IsNull(Me.cboAddress) Then
strWhere = strWhere & "([Address] = '" & Me.cboAddress & "') AND "
End If
If Not IsNull(Me.cboBiaName) Then
strWhere = strWhere & "([BIA name (Allocated to)] = '" & Me.cboBiaName & "') AND "
End If
If Not IsNull(Me.cboMhaName) Then
strWhere = strWhere & "([MHA name] = '" & Me.cboMhaName & "') AND "
End If
If Not IsNull(Me.txtDolsSearch) Then
strWhere = strWhere & "([Dol] = " & Me.txtDolsSearch & ") AND "
End If
If Not IsNull(Me.txtAisSearch) Then
strWhere = strWhere & "([AIS Number] = " & Me.txtAisSearch & ") AND "
End If
'2 check boxes for 1 field
If Me.chkGranted = False And Me.chkInProgress = False Then
'do nothing
ElseIf Me.chkGranted = True And Me.chkInProgress = False Then
strWhere = strWhere & "([Outcome] = 'Granted') AND "
ElseIf Me.chkGranted = False And Me.chkInProgress = True Then
strWhere = strWhere & "([Outcome] = 'In Progress') AND "
ElseIf Me.chkGranted = True And Me.chkInProgress = True Then
strWhere = strWhere & "([Outcome] = 'Granted' or [Outcome] = 'In Progress') AND "
End If
'************************************************* **********************
'Chop off the trailing " AND ", and use the string as the form's Filter.
'************************************************* **********************
'See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub