Connecting Tech Pros Worldwide Forums | Help | Site Map

Access 2007 Crosstab query with parameters

Newbie
 
Join Date: Nov 2008
Posts: 3
#1: Nov 12 '08
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a column heading.

I want to be able to select complaints which were resolved in a particular date range (field is Date resolved). This field is in the original query but not the crosstab.

How do I do it?

Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#2: Nov 12 '08

re: Access 2007 Crosstab query with parameters


In the query that the crosstab query is based off.

In the criteria for the field [Date Resolved] put the following
Expand|Select|Wrap|Line Numbers
  1. [Date Resolved]>=[Please Enter From Date] and [Date Resolved]<=[Please Enter To Date] 
  2.  
the criteria is referencing the fields [Please Enter From Date] and [Please Enter To Date]. Since these 2 fields don't exist in your query, (I hope), an input box will popup for each of them asking you to input their value.

PS
You can use the BETWEEN function instead if you want.
Newbie
 
Join Date: Nov 2008
Posts: 3
#3: Nov 12 '08

re: Access 2007 Crosstab query with parameters


Thank you for replying. I tried that first off but when I try to run the crosstab query I get an error message:

"The Microsoft Office Access database engine does not recognize '[startdate]' as a valid field or expression."
Newbie
 
Join Date: Nov 2008
Posts: 3
#4: Nov 12 '08

re: Access 2007 Crosstab query with parameters


Got it!

SQL is:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [start] DateTime, [end] DateTime;
  2. TRANSFORM Count(qResolved.ComplaintNumber) AS CountOfComplaintNumber
  3. SELECT qResolved.[Complaint type], Count(qResolved.ComplaintNumber) AS [Total Of ComplaintNumber]
  4. FROM qResolved
  5. WHERE (qResolved.[Date Resolved] BETWEEN [start] AND [end])
  6. GROUP BY qResolved.[Complaint type]
  7. PIVOT qResolved.Outcome;
  8.  
Member
 
Join Date: Feb 2008
Posts: 58
#5: Dec 18 '08

re: Access 2007 Crosstab query with parameters


I am having hell with my Cross tab query. I am trying to arrive at a table that displays a summary of job status by staff over a given period.

Here is the SQL I am using
TRANSFORM Count(SupportLogs.Status) AS CountOfStatus
SELECT SupportLogs.SupportStaff
FROM SupportLogs
WHERE (((SupportLogs.DateReported) Between [Forms]![frmSearch]![BegDate] And [Forms]![frmSearch]![EndDate]))
GROUP BY SupportLogs.SupportStaff
PIVOT SupportLogs.Status;

When I run this it gives me an error stating that "[Forms]![frmSearch]![BegDate]" is not a valid field name or expression.

I get the same thing if i try to use parameters and have it prompt for the date when it is executed.
Help Please!
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#6: Dec 18 '08

re: Access 2007 Crosstab query with parameters


I havent used a pivot query in access that looks quite like yours so this is only a guess.
I am assuming that you are using text boxes for the dates
Try putting a .Text on the end of those controls.

[Forms]![frmSearch]![EndDate].Text

This statement
Quote:
I get the same thing if i try to use parameters and have it prompt for the date when it is executed.
leads me to believe it won't work, but worth a try
Reply


Similar Microsoft Access / VBA bytes