Hi all, I need some help to filter my subform, which is made by query .
What I miss and what needs to be added to the code to work?
What I miss and what needs to be added to the code to work?
Code:
Private Sub cmdSearch_Click()
Dim strQuery As String
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
strQuery = "qry_Inspections"
If Not IsNull(Me.cboWorker) Then
strWhere = strWhere & "([Worker] = """ & Me.cboWorker & """) AND "
End If
If Not IsNull(Me.txtFrom) Then
strWhere = strWhere & "([DateTask] >= " & Format(Me.txtFrom, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtTo) Then
strWhere = strWhere & "([DateTask] < " & Format(Me.txtTo + 1, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else '
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub