parameter verison of >=#4/1/2005# And <=#4/30/2005#

T

tdmailbox

I have a access query hitting a sql back end.

I am looking for dates for a certain field within a month
=#4/1/2005# And <=#4/30/2005#

gives me the results I am looking for. But I want to use pop ups that
ask the user the dates
=[from] And <=[to] returns the wrong values it misses for dates in the middle of the month
=#[from]# And <=#[to]# is not allowed by access.

what is the correct syntax for this?
 
V

Van T. Dinh

* Even though the square brackets will work, I recommend using "FromDate"
and "ToDate" since "From is a keyword.

* Use:
= [FromDate] AND <= [ToDate]

but make sure you declare the data type of the variable. You can declare
the data type using the Menu Query / Parameters ...

--
HTH
Van T. Dinh
MVP (Access)




I have a access query hitting a sql back end.

I am looking for dates for a certain field within a month
=#4/1/2005# And <=#4/30/2005#

gives me the results I am looking for. But I want to use pop ups that
ask the user the dates
=[from] And <=[to] returns the wrong values it misses for dates in the
middle of the month
=#[from]# And <=#[to]# is not allowed by access.

what is the correct syntax for this?
 
F

fredg

I have a access query hitting a sql back end.

I am looking for dates for a certain field within a month
=#4/1/2005# And <=#4/30/2005#

gives me the results I am looking for. But I want to use pop ups that
ask the user the dates
=[from] And <=[to] returns the wrong values it misses for dates in the middle of the month
=#[from]# And <=#[to]# is not allowed by access.

what is the correct syntax for this?

It is a Date datatype field, right?
As criteria on the DateField, either:
Between [FromDate] and [ToDate]
or
=[FromDate] and <= [ToDate]
should work.

You say it misses dates in the middle of the month. If it is a valid
date datatype, it should return all dates from the From to the To
dates. If it misses only the last date it is probably because you have
a time as well as date value in the field, and 6/30/2005 is not the
same as 6/30/2005 11:15:05 AM. If so, one easy workaround is to
simply enter the next day, i.e. 7/1/2005.
For other workarounds, post back.
 
Top