Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables in Queries

Status
Not open for further replies.

mRcooper

Programmer
Joined
Dec 12, 2002
Messages
6
Location
GB
Hi,

I would like to perform a 'Between date' function on a query, where the dates are variables.

These dates are obtained from two other queries, qMinDate and qMaxDate, which are both 1 col, 1 field.

How to I insert qMinDate/qMaxDate into the 'between' statement in the query?
 
try this as the criteria for the you want to query

Between [qMinDate] And [qMaxDate]

This assumes thet these fields are available to the Query.

The following will prompt the user for the dates if that helps

Between [Enter Start Date] And [Enter End date]

Cheers



Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Another possibility, if your qMinDate and qMaxDate queries are as simple as they sound, is to use the DMin and DMax functions instead of these queries, as in:

BETWEEN DMin("[Date]","TableName]","Min Criteria If Any")AND DMax ("[Date]","TableName]","Max Criteria If Any")

Just a thought.
 
ObjectRequired's solution is clever, but I don't think he got the details right.

Assuming qMinDate's column is called MinDate, and qMaxDate's is MaxDate, try this:
BETWEEN DLookup("MinDate", "qMinDate") AND DLookup("MaxDate", "qMaxDate") Rick Sprague
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top