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

edit crosstab query by form

Status
Not open for further replies.

MICKI0220

IS-IT--Management
Jul 20, 2004
337
US
I have a crosstab query that I need the date to be taken from a form when it runs.
This is the current code.

Code:
TRANSFORM Sum(HrsForCrossTab.Hours) AS SumOfdHoursWorked_qty
SELECT HrsForCrossTab.EmployeeId, HrsForCrossTab.JobNo
FROM HrsForCrossTab
GROUP BY HrsForCrossTab.EmployeeId, HrsForCrossTab.JobNo
PIVOT "Date" & DateDiff("d",#8/5/2012#,[Date_hr]+1) & [EarningCode];

How do I get the date that is in this code to be whatever is in a forms text box such as [frmTest]![testdate]

Thanks in advance

Micki
 
You must set the data type of the parameters with SQL like:
[CODE sql]
PARAMETERS [Forms}![frmTest]![testdate] DateTime;
TRANSFORM Sum(HrsForCrossTab.Hours) AS SumOfdHoursWorked_qty
SELECT HrsForCrossTab.EmployeeId, HrsForCrossTab.JobNo
FROM HrsForCrossTab
GROUP BY HrsForCrossTab.EmployeeId, HrsForCrossTab.JobNo
PIVOT "Date" & DateDiff("d",[Forms]![frmTest]![testdate],[Date_hr]+1) & [EarningCode];
[/code]
You might also want to set the column headings property of the crosstab query.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top