add filter to form

  • Thread starter Thread starter Trotsky
  • Start date Start date
T

Trotsky

Hi all,
Its probably very simple but How do I add a filter to a form that will
filter records between two dates that the user enters in a text box
Thanks
 
Use a query for the record source of your form. Make one of the criteria of
that query something like:

Between Forms!myForm!startDate and Between Forms!myForm!endDate

Where you have two controls (can be unbound) named "StartDate" and
"EndDate". You'll need to requery after entering the dates.
-Ed
 
Cheers,
How do I requery?
I used a command button to rerun the query but it just displays the form
and refresh form dosn't work,
You may be able to tell I'm just beginning to use access
Cheers again
 
In the After Update event of your [EndDate] control put code like:
Forms!myForm.Requery

that will requery the record source of your form, (which is the query with
your date range criteria) and show the filtered records. You can view the
different number of records on the navigation/record selector bar.
-Ed
 
Hi Again,
Thanks for your help,
BUT
I am getting THE EXPRESSION YOU ENTERED CONTAINS INVALID SYNTAX
when I use Between Forms!Breakthrutime!startDate and Between Forms!
Breakthrutime!endDate
My form is called Breakthrutime...

and when I use Forms!Breakthrutime.Requery
I get ....CLIENT DATABASE CANT FIND THE MACRO 'Forms!Breakthrutime'
I presume I'm missing something obvious
Sorry about this
Cheers
John
 
OK, last attempt. The criteria expression in your query should be:

Between Forms!Breakthrutime!startDate and Forms!Breakthrutime!endDate

Note that "between...and" is only used once.

"Forms!Breakthrutime.Requery" (without the "") should be in the After Update
event line of both your Start/End Date controls. If that is really your
form name (Breakthrutime), then the form's record source will be re-queried
any time either date is changed.
-Ed
 
All I had to do was After Update=Forms!Breakthrutime.Requery
DOH!
Its working fine now.
Thanks for all your help
 
Back
Top