Your dates need to be delimited by the symbol "#" to tell Access that they
are dates. Try this:
DoCmd.ApplyFilter , "[TMS_DATE] >= #" & DateValue(!txtWkStart) & _
"# And [TMS_DATE] <= #" & DateValue(!txtWkEnd) & "#"
"MikeC" <(E-Mail Removed)> wrote in message
news:L2Vdd.17055$(E-Mail Removed)...
> I'm developing a time sheet form in AXP that filters records using two
> unbound text boxes to define the upper and lower limits of a date range.
> The form itself is bound to a recordsource query. When I attempt to apply
> the filter using the below code, the form fails to display any records at
> all.
>
> The below code runs in a command button's On Click event procedure.
>
> With Me
> !txtWkStart = DateAdd("d", -7, !txtWkStart)
> !txtWkEnd = DateAdd("d", -7, !txtWkEnd)
> .FilterOn = True
> DoCmd.ApplyFilter , "[TMS_DATE] >= " & DateValue(!txtWkStart) & "
> And [TMS_DATE] <= " & DateValue(!txtWkEnd)
> End With
>
> Below is an actual text string that was passed to the above
> DoCmd.ApplyFilter method:
>
> [TMS_DATE] >= 10/18/2004 And [TMS_DATE] <= 10/24/2004
>
> In addition, I have also tried using the below lines immediately after
> executing the above code, but the form continues to display zero records:
>
> DoCmd.RunCommand acCmdApplyFilterSort
> Me.Requery
>
> No error messages display at all. I have stepped the code through the
> debugger and it appears to execute just fine, except for the part where
it's
> supposed to display my data. ;-)
>
> Also, if I toggle-off the "Apply Filter" button using the built-in tool
bar,
> then *all* records display.
>
> I just can't seem to filter today. What am I missing?
>
>
>
|