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

Looking for help with crosstab queries and their relationship to forms

Status
Not open for further replies.

MConlisk

IS-IT--Management
Dec 4, 2006
3
US
I am having a problem using a form to supply dates to a crosstab query. I have a form named "frmGetDates_ESS" and it has two text fields "dfrom" and "dto". Here is the SQL view of my query.

Code:
PARAMETERS [from] DateTime, [to] DateTime;
TRANSFORM Count(dbo_CallLog.ID) AS CountOfID
SELECT [AnsweredByFirstName] & " " & [answeredbylastname] AS Name
FROM dbo_CallLog
WHERE (((dbo_CallLog.StartTime) Between [forms]![frmGetDates_ESS]![dfrom] And [forms]![frmGetDates_ESS]![dto]) AND ((dbo_CallLog.Direction)=0) AND ((dbo_CallLog.Result)<3) AND ((dbo_CallLog.ToID)=3194 Or (dbo_CallLog.ToID)=5182) AND ((DateDiff("s",[starttime],[stoptime]))>0))
GROUP BY [AnsweredByFirstName] & " " & [answeredbylastname]
PIVOT Format([StartTime],"hh");

All I get is an error message:
"The Microsoft Jet database engine does not recognize '[forms]!frmGetDates_ESS]![dfrom.[Caption]' as a valid field name or expression"

Please help if you can. I am not sure if I can use a form to supply dates to a crosstab query. Thanks

Matthew
 
Replace this:
PARAMETERS [from] DateTime, [to] DateTime;
with this:
PARAMETERS [forms]![frmGetDates_ESS]![dfrom] DateTime, [forms]![frmGetDates_ESS]![dto] DateTime;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ok, now it will go through with out an error. but I dont get any data. I can run the query without the form open, manually enter the dates in the pop-ups, and the data is there. But if I open the form and type the dates in the text boxes I get no data. Is there anything else I can try.
 
Ok. Thank you very much. I got it to work. I had to add .[value] to the end of the [forms]![frmGetDates_ESS]![dfrom] and [forms]![frmGetDates_ESS]![dto]. so now my SQL looks like this.

Code:
PARAMETERS [forms]![frmGetDates_ESS]![dfrom].[value] DateTime, [forms]![frmGetDates_ESS]![dto].[value] DateTime;
TRANSFORM Count(dbo_CallLog.ID) AS CountOfID
SELECT [AnsweredByFirstName] & " " & [answeredbylastname] AS Name
FROM dbo_CallLog
WHERE (((dbo_CallLog.StartTime) Between [forms]![frmGetDates_ESS]![dfrom].[value] And [forms]![frmGetDates_ESS]![dto].[value]) AND ((dbo_CallLog.Direction)=0) AND ((dbo_CallLog.Result)<3) AND ((dbo_CallLog.ToID)=3194 Or (dbo_CallLog.ToID)=5182) AND ((DateDiff("s",[starttime],[stoptime]))>0))
GROUP BY [AnsweredByFirstName] & " " & [answeredbylastname]
PIVOT Format([StartTime],"hh");

Thanks again

Matthew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top