Date reference as criteria in query

  • Thread starter Thread starter Tim Brown
  • Start date Start date
T

Tim Brown

Hi,

I'm trying to restrict a query through a date range.

The query, which has against a date field the
criteria "Between #date# and #date#", works fine when date
is a specified value (that is, specified within the query).

BUT, when date is a reference to a control on a Form, it
always returns no records.

Criteria I'm using is: "Between [Forms]![Main Menu]!
[dFrom] And [Forms]![Main Menu]![dTo]"

This always returns zero records. Is this the correct way
to refer to a date on a form, or is there another way to
do it?

Thanks,
Tim
 
It is possible that the entries in the Fprm Controls are
not being recognised as dates. However, you can set the
data type of the parameters. In the DesignView of the
Query, use the menu Query / Parameters. In the left
column, type the references to the Controls on separate
rows. In the right column, select DateTime. OK to accept
and try your Query again.

Obviously, the Form needs to be open and there are valid
date entries in the Controls for your Query to get the
values.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top