Your SQL statement looks good to me.
PARAMETERS [Forms]![Main Menu]![Beginning Date] DateTime
, [Forms]![Main Menu]![Ending Date] DateTime;
TRANSFORM Val(Nz(Count(dbo_HPD_HelpDesk.Status),0)) AS CountOfStatus
SELECT dbo_HPD_HelpDesk.Priority
, Switch([Priority] Like "[0]*","Low"
,[priority] Like "[1]*","Medium"
,[Priority] Like "[2]*"
,"High",[Priority] Like "[3]*","Urgent") AS PriorityName
, Count(dbo_HPD_HelpDesk.Status) AS CountOfStatus1
FROM dbo_HPD_HelpDesk
WHERE DateAdd("s",[arrival_time],#1/1/1970#)
Between [Forms]![Main Menu]![Beginning Date] And [Forms]![Main Menu]![Ending
Date]
GROUP BY dbo_HPD_HelpDesk.Priority
, Switch([Priority] Like
"[0]*","Low",[priority] Like "[1]*","Medium",[Priority] Like
"[2]*","High",[Priority] Like "[3]*","Urgent")
PIVOT dbo_HPD_HelpDesk.Status;
Things to check:
Names of the fields - make sure they are all correct . Normally you will
see the message when Access sees something it can't interpret as a field or
a parameter in a crosstab. So if a field is mistyped then the query
believes it is a parameter. Crosstabs require parameters to be defined.
Is [Arrival_Time] EVER null (Blank)? That can cause an error. Perhaps you
could try
WHERE DateAdd("s",IIF([arrival_time] is Null,0,[Arrival_Time]),#1/1/1970#)
Double check the SQL and make sure Access hasn't done something like adding
extra brackets around the parameters. Sometimes Access will do
PARAMETERS [[Forms]![Main Menu]![Beginning Date]] DateTime
, [[Forms]![Main Menu]![Ending Date]] DateTime;
Things to try to identify the source of the problem
Try Hard Coding the dates and see if the query works.
Try removing the fields one by one
Try removing the where clause. If that solves the problem that try hard
coding the dates. If you still have the problem then look at the
arrival_time field.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
nms said:
Hi John-thanks for responding-I really need to get this to work as there
are
lots of crosstab reports to complete each month!
I tried what you suggested and it now does not even ask for a date to
enter
and returns no data in the query when I try to run it. I must be doing
something wrong.
1. I declared the parameters in the query under Query, Parameters:
[Forms]![Main Menu]![Beginning Date]
[Forms]![Main Menu]![Ending Date]
2. in the criteria for the field in the query I entered (this is a field
that I created to change the date from the Unix timestamp to a date that
Access will recognize (DateAdd("s",[arrival_time],#1/1/1970#):
Between [Forms]![Main Menu]![Beginning Date] And [Forms]![Main
Menu]![Ending
Date]
3. I created two unbound text box controls on the main menu form, called
one Beginning Date and the other Ending Date (I take that I don't have to
enter anything in the control source). When I try to open the report from
the Main Menu with a command button that I created, I get the following
error
messge:
The Microsoft Jet database engine does not recognize " as a valid field
name
or expression
Here is the SQL Code:
PARAMETERS [Forms]![Main Menu]![Beginning Date] DateTime, [Forms]![Main
Menu]![Ending Date] DateTime;
TRANSFORM Val(Nz(Count(dbo_HPD_HelpDesk.Status),0)) AS CountOfStatus
SELECT dbo_HPD_HelpDesk.Priority, Switch([Priority] Like
"[0]*","Low",[priority] Like "[1]*","Medium",[Priority] Like
"[2]*","High",[Priority] Like "[3]*","Urgent") AS PriorityName,
Count(dbo_HPD_HelpDesk.Status) AS CountOfStatus1
FROM dbo_HPD_HelpDesk
WHERE (((DateAdd("s",[arrival_time],#1/1/1970#)) Between [Forms]![Main
Menu]![Beginning Date] And [Forms]![Main Menu]![Ending Date]))
GROUP BY dbo_HPD_HelpDesk.Priority, Switch([Priority] Like
"[0]*","Low",[priority] Like "[1]*","Medium",[Priority] Like
"[2]*","High",[Priority] Like "[3]*","Urgent")
PIVOT dbo_HPD_HelpDesk.Status;