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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include parameters in query output 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB

In simplified form I have a table with fields Activity and Date.

I'd like to query this between a StartDate and EndDate and produce output that includes a field Period as 'StartDate to EndDate'.

So the output would look like this

Activity, Period
Activity 1, 1/2/15 to 12/2/15
Activity 2, 1/2/15 to 12/2/15
etc
 
How about:

[tt]Select tbl.Activity, '1/2/15 to 12/2/15' As Period
From tbl
Where tbl.SameDateField Between ...
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
First, I would recommend not using parameter queries faq701-6763. Also Date is the name of a function and should be avoided as the name of a field.

If you use controls on a form you can create columns with the expressions from your criteria. You could do the same with your parameter prompts.

SQL:
SELECT Activity, Forms!frmDates![txStartDate] & " - " & Forms!frmDates![txtEndDate] AS Period
FROM tblActivities
WHERE ActivityDate Between Forms!frmDates![txStartDate] and Forms!frmDates![txtEndDate]


SQL:
SELECT Activity, [Enter Start Date] & " " & [Enter End Date] As Period
FROM tblActivities
WHERE ActivityDate Between [Enter Start Date] And [Enter End Date];

Duane
Hook'D on Access
MS Access MVP
 
Thanks again Duane, using form controls is exactly what I want to do so the same query can be run when one of twelve periods is selected from an option group.

Your constant help is very much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top