Applying a filter from within a form

D

Douglas J. Steele

What's the code you're trying to use? It should be something like:

Me.Filter = "DateField Between #" & Me.Start_Date & "# And #" & Me.End_Date
& "#"
Me.FilterOn = True

(replace DateField with the appropriate field name)

Now, Start_Date and End_Date must be in mm/dd/yyyy format, regardless of
what your regional settings are. (That's not strictly true: it can be any
unambiguous format, such as yyyy-mm-dd or dd mmm yyyy. The point is, it
won't work if the date's in dd/mm/yyyy format and dd is 12 or less) To
ensure it's done properly, I'd advise using the following instead of what
I've shown above:

Me.Filter = "DateField Between " & Format(Me.Start_Date, "\#mm\/dd\/yyyy\#")
& "And " & Format(Me.End_Date, "\#mm\/dd\/yyyy\#")
 
A

Ant

I have a form based on a query that uses criteria selected by a user from
several unbound combo box on another form, this fillers the data so far but
I would now like to let the user filter the data further using something
like Between #[Start_Date]# And #[End_Date]# . Start_Date & End_Date being
two unbound field in the form header. And ether using the after update
property of the End_Date field or a RUN button the form should filter. I
have spent a day trying to do this to no avail, is it possible, am I barking
up the wrong tree? If so any other suggestions to achieve a similar result
would be appreciated.



Thanks
 
A

Ant

Thanks Doug,

I think I understand, I'll have a go and keep my fingers crossed.

In answer to your question I was'nt useing code, I was just setting the
criteria in the query e.g. Between forms![Form_Name]![Start_Date] And
Forms![Form_Name]![End_Date]

Thanks again


Douglas J. Steele said:
What's the code you're trying to use? It should be something like:

Me.Filter = "DateField Between #" & Me.Start_Date & "# And #" & Me.End_Date
& "#"
Me.FilterOn = True

(replace DateField with the appropriate field name)

Now, Start_Date and End_Date must be in mm/dd/yyyy format, regardless of
what your regional settings are. (That's not strictly true: it can be any
unambiguous format, such as yyyy-mm-dd or dd mmm yyyy. The point is, it
won't work if the date's in dd/mm/yyyy format and dd is 12 or less) To
ensure it's done properly, I'd advise using the following instead of what
I've shown above:

Me.Filter = "DateField Between " & Format(Me.Start_Date, "\#mm\/dd\/yyyy\#")
& "And " & Format(Me.End_Date, "\#mm\/dd\/yyyy\#")

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ant said:
I have a form based on a query that uses criteria selected by a user from
several unbound combo box on another form, this fillers the data so far but
I would now like to let the user filter the data further using something
like Between #[Start_Date]# And #[End_Date]# . Start_Date & End_Date being
two unbound field in the form header. And ether using the after update
property of the End_Date field or a RUN button the form should filter. I
have spent a day trying to do this to no avail, is it possible, am I barking
up the wrong tree? If so any other suggestions to achieve a similar result
would be appreciated.



Thanks
 

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

Filter on date problem 8
Field Size Dilemma 12
Date Formats & Display 5
Filter between two dates 4
Funny Split Form Bug? 0
Date Formatting 1
displaying dates in UK format 10
Check for empty records on filter 2

Top