Filtering records by date

sal

Registered User.
Local time
Yesterday, 19:23
Joined
Oct 25, 2009
Messages
52
I am trying to allow users to filter a set of records by date. My reference to the filter control is as follows:

If Nz(Me.DateFilter, 0) > 0 Then 'TargetType
If Len(Nz(strFilter)) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "#Date# = '" & Me.DateFilter & "'"
bFilter = True
End If

Where DateFilter is the unbound control and Date is the field on the form to be filtered.

I have used both text and numerical filters such as this successfully before, and understand the differences in syntax there. But I obviously have the syntax wrong for the date data type, and a couple of hours of experimenting and searching online for help have not produced a solution. Thank you in advance for guidance.
 
I found an example of dates being passed this way:

If Nz(Me.DateFilter, 0) > 0 Then 'TargetType
If Len(Nz(strFilter)) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "[Date (mm/dd/yyyy)] = #" & Me.DateFilter & "#"
bFilter = True
End If

And indeed, answered my own question.
 

Users who are viewing this thread

Back
Top Bottom