You have tried to use an SQL type statement as a filter.
This should work if you are using American dates (mm/dd/yyyy), but will need modification for English Dates (dd/mm/yyyy)
I strongly urge you not to have spaces in Field Names in tables, Conrol Names in Forms & Reports and all objects in the database window. If there are spaces, the words have to be surrounded with square brackets [Date Occurred] instead of DateOccurred
I have 2 Command buttons on my form, one for US dates and one for UK Dates
-
Option Compare Database
-
Option Explicit
-
-
Private Sub CmdUSSearch_Click()
-
-
Dim strFltr
-
-
If IsNull(Me.DOF) Or IsNull(Me.DOT) Then
-
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
-
Me.DOF.SetFocus
-
Else
-
strFltr = "(DateOccurred >= #" & Me.DOF & "# And DateOccurred <= #" & Me.DOT & "#)"
-
Me.Filter = strFltr
-
Me.FilterOn = True
-
End If
-
-
End Sub
-
-
Private Sub CmdUKSearch_Click()
-
-
Dim strFltr
-
-
If IsNull(Me.DOF) Or IsNull(Me.DOT) Then
-
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
-
Me.DOF.SetFocus
-
Else
-
strFltr = "(DateOccurred >= #" & Format(Me.DOF, "mm/dd/yyyy") & "# And DateOccurred <= #" & Format(Me.DOT, "mm/dd/yyyy") & "#)"
-
Me.Filter = strFltr
-
Me.FilterOn = True
-
End If
-
-
End Sub
-
Choose which one applies to you.
Phil