Filter between two dates

S

senseinobaka

Greetings Board:

How can a tabular form be filtered by date.

This is what I have tried:
I made a tabular form that is linked to my "customer visits" table.
I added two text boxes onto the tabular form's heading named Box1 and Box2.
I made a command button that when clicked runs an applyfilter macro.
the macro is linked to a query that searches the customer visit table by
date, the criteria is:

|| Between Forms!Formname!Box1 And Forms!Formname!Box2 ||

I also tried:

|| Between #Forms!Formname!Box1# And #Forms!Formname!Box2# ||

Please help me is a better way to do this. All I get when I click the cmd
button an error dialouge.
 
A

Allen Browne

If you have placed this criteria in the query that provides the records for
the form, then your button could just Requery the form. It doesn't need to
apply a filter.

That approach works, but has some limitations. If you don't enter both
dates, you don't get many records, and some versions can ask for the
parameters again when you open or close the form. A more flexible solution
would be to omit the criteria from the query, and instead use the command
button's click event to build the filter string.

See:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
The example talks about applying the filter to a report, but it identical
for applying the filter to a form. You just end up using:
Me.Filter = strWhere
Me.FilterOn = True
instead of the OpenReport line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top