"SELECT * FROM reservation WHERE " & Me.txtfrom & " BETWEEN from_date
AND exp_date"
A number of problems. Can you be sure that txtFrom will _always_ refer to
a DateTime field? If you have such a lot of DateTime fields in a table,
it suggests a probably Design Problem. This perhaps should be a different
query with the txtFrom moved into the WHERE clause...
Second, using BETWEEN does not always work as planned. Dates are stored
as real numbers not integers, so #2005-01-01 21:30# falls outside the
range BETWEEN something AND #2005-01-01#. Unless you can absolutely
guarantee that nowhere have you introduced any time value data, then you
are safer using proper floating point comparisons:
"...WHERE " & Format(FromDate,strJetDt) & " <= MyField " & _
" AND MyField < " & Format(ToDate+1, strJetDt)
Note that the second boundary goes up to but not including the following
midnight.
I want to know am I bound to use american DATE format?
No: but you have a very limited choice, and DMY is not one of them. This
is so that Jet developers can just write code without having to worry
about regional settings. A date like #12/04/2000# will be interpreted as
December everywhere. Beware of this but though: a date like #20/04/2000#
should raise an error but doesn't.
Essentially, the choice is
strJetDt = "\#mm\/dd\/yyyy\#" ' USAian format
or
strJetDt = "\#yyyy\-mm\-dd\#" ' ISO 8601 standard
If, like me, you prefer to think of your code adhering to sensible
international standards, you can reliable use the second version. Note
that in either form, the separators can be critical.
Hope that helps
Tim F