Have a Query return results within a date range

B

BZeyger

I have a form that refers to a query that contains:

Project Name
Start Date
End Date

The form has 2 text boxes (Start Date and End Date) and a command button.
This is where the user would enter a date range. Once the command button is
clicked, the query (located in a subform) would return the results that fall
in the date range.

How would I do this? Would I put something in the query or would I have to
code something in the command button.?
 
J

Jeff Boyce

The command button "opens" the query.

The query needs to include a date/time field to compare to, and would use
something like the following for the selection criterion under that
date/time field:

Between Forms!YourFormName![Start Date] And Forms!YourFormName![End
Date]

If that doesn't (quite) work, you'll need to define these two as parameters,
of type Date/Time, inside the query design window.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

KARL DEWEY

Would I put something in the query
Yep.

Use this as criteria on your date field --
Between [Forms]![YourFormName]![Start Date] And
[Forms]![YourFormName]![End Date]
 
J

Jeff Boyce

Having looked over other responses, I need to get some clarification...

Is it your form that has two controls ([Start Date] and [End Date]), or are
you saying that your underlying table has two date/time fields?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John W. Vinson

Having looked over other responses, I need to get some clarification...

Is it your form that has two controls ([Start Date] and [End Date]), or are
you saying that your underlying table has two date/time fields?

Or both... and you want to return records where there is any overlap between
the two ranges?
 
B

BZeyger

The form contains the text boxes for Start Date and End Date. The subform
appears in a datasheet view which shows a Name, start date and end date

Jeff Boyce said:
Having looked over other responses, I need to get some clarification...

Is it your form that has two controls ([Start Date] and [End Date]), or are
you saying that your underlying table has two date/time fields?

Regards

Jeff Boyce
Microsoft Office/Access MVP

BZeyger said:
I have a form that refers to a query that contains:

Project Name
Start Date
End Date

The form has 2 text boxes (Start Date and End Date) and a command button.
This is where the user would enter a date range. Once the command button
is
clicked, the query (located in a subform) would return the results that
fall
in the date range.

How would I do this? Would I put something in the query or would I have to
code something in the command button.?
 

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

Top