Problems with Cross Tab Query Parameters

MarsBars

New Member
Joined
May 21, 2014
Messages
27
Ok, So according to the internets, I'm doing this right. However, I am not getting the desired result.

I am using a crosstab query with the added stipulation that I need to only extract data between 2 dates. I put the parameters in like so:

Between [Start Date] And [End Date] l Date/Time

However, when I run the query, it asks for only one parameter, and the text on the msg box is "Between [Start Date] And [End Date]"

What am I doing wrong here?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Exactly what is the purpose "l Date/Time" that is after [End Date]?
Is that really there?

Can you switch your query to SQL View and post the SQL code here?
 
Upvote 0
Hi Joe,

I couldn't figure out how to post a picture easily. It was supposed to show the parameter type in the data column. Admittedly, a bad attempt.

Anyway,

Here's the query in SQL view:

Code:
PARAMETERS [Between [Start Date] And [End Date]] DateTime;
TRANSFORM Count(Samples_Lab.ID) AS [Total Of ID]
SELECT Samples_Lab.Operator
FROM Samples_Lab
GROUP BY Samples_Lab.Operator, Samples_Lab.Completion
PIVOT Samples_Lab.ProcessType;
 
Upvote 0
Looks like you have too many square brackets. Everything within a single set of square brackets is considered a single parameter.
I am not sure what the DateTime thing at the end of your Parameter line is for either. Maybe you are doing a Parameter Query is some way I am unfamiliar with.
This is the way that I am familiar with: Use parameters to ask for input when running a query - Access

Where you have actually entered the parameters in the Query Builder?
Under which field?
And Exactly how is it entered on the Criteria line?
 
Upvote 0
I wasn't able to enter the parameters into the "Criteria" line in the design view. It worked when I did it for the "standard" queries, but the crosstab queries throw an error.

I entered it up in the parameters window that you acccess using the "Query Tools" tab on the ribbon.

I'm using Access 2010 if that makes a difference.

On the line in the parameters window(for lack of a better word): Between [Start Date:] And [End Date:]

Thanks for trying to help me. I just started learning VBA in excel a few months ago. So trying to learn access as well has been frustrating.
I apologize if I'm using the wrong terminology.
 
Upvote 0
Ok, I think I've figured it out.

I apparently needed to declare/define my parameters ([Start Date] & [End Date]) as date/Time before I could use them in the criteria for the corsstab query.

Thanks for your help Joe. Sorry I took up so much of your time. That article you linked me to helped in the end. When I got to the bottom, it discussed declaring the parameters.
 
Upvote 0
Glad they helped, because I didn't have too much more I could have added due to the fact that:
1. I rarely used Cross-Tab Queries;
2. I have never really tried using Parameters like that (I usually create my own criteria Forms and build the SQL code of the query on-the-fly using SQL);
3. I am still on Access 2007.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top