I am trying to update my access database. I have addedd a textbox called txtSearch on the form. The intention is to search and filter records in the a table called Inspections_LogBookTable as the user types in the textbox called txtSearch. The code works perfectly for text fields but it cannot filter date fields.
the code I'm using is below
Some of the columns in the table are ; Invoice_Number, Amount, Purpose (text data type) and Inspection_Date (Date datatype).
Any help on how to filter the fields with date data type
the code I'm using is below
Code:
Private Sub txtSearch_KeyUp(KeyCode As Integer, Shift As Integer)
On Error GoTo Err1
Dim FilterValue As String
'Apply or update filter based on user input.
If Len(Me.txtSearch.Text) > 0 Then
FilterValue = Me.txtSearch.Text
Me.Form.Filter = "[Inspections_LogBookTable]![Invoice_Number] LIKE '*" & FilterValue & "*' or [Inspections_LogBookTable]![Amount] LIKE '*" & FilterValue & "*' or [Inspections_LogBookTable]![Purpose] LIKE '*" & FilterValue & "*' ' or [Inspections_LogBookTable]![Inspection_Date] LIKE '*" & FilterValue & "*'""
Me.FilterOn = True
'Retain filter text in search box after refresh.
Me.txtSearch.Text = FilterValue
Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
Else
' Remove filter.
Me.Filter = ""
Me.FilterOn = False
Me.txtSearch.SetFocus
End If
Exit Sub
Err1:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly, "Error ..."
End Sub
Some of the columns in the table are ; Invoice_Number, Amount, Purpose (text data type) and Inspection_Date (Date datatype).
Any help on how to filter the fields with date data type