Discussion Locked

Parameter in a Crosstab Query

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is it possible to use a parameter in a crosstab query for a field that is not included as part of the crosstab? For example, I would like a date range parameter prompt, but the date field is not part of the aggregrate crosstab. Thanks!

5 replies

by sl-campbell

It is possible to pass criteria to a Transform/Crosstab query, but not as a parameter as far as I know.

You can hard code the Transform Select statement, build a recordset and then pass assign the value of a text box or variable to the criteria in the WHERE section of the statement.

by syscokid

I'm no Access expert but I did create a Crosstab query once that allowed me to pass a date parameter.

I don't remember exactly how I set it up in design view, but here's the SQL statement. Maybe you can modify it to suit your needs. (It's buggy, it prompts twice for dates).

PARAMETERS [#Begin Date MM/DD/YY#] DateTime, [#End Date MM/DD/YY#] DateTime;
TRANSFORM Count([YourTable].num) AS [The Value]
SELECT [YourTable].[YourField]
FROM [YourTable]
WHERE (((([YourTable].[Date])>=[BeginDate #MM\DD\YY#])<=[#End Date MM\DD\YY#]))
GROUP BY [YourTable].[YourRowField]
PIVOT [YourTable].[YourColumnField] In ("Value1","Value2","Value3","Value4");

This discussion is closed to new replies.