Solved

Setting column headings for crosstab query causes error

Posted on 2012-03-29
3
402 Views
Last Modified: 2012-03-29
Experts,

I need to add a subform that is based on a crosstab query. This means I need to set the column headings in the query. However, when I do this, running the query produces the error message that says the expression is typed incorrectly or is too complex. It runs fine without the column headings being set.

At first I thought the problem may have something to do with the column headings being numeric, but changing them to text did not help.

Thanks, Dale

PARAMETERS [TempVars]![SelectedCrop] Long, [TempVars]![SelectedCountry] Long, [TempVars]![SelectedDriver] Long;
TRANSFORM Avg(qryExpertOpinionSub1.Decrease) AS AvgOfDecrease
SELECT tblProductMainGroups.ProductMainGroup AS Product, tblClasses.Class
FROM tblClasses INNER JOIN ((qryExpertOpinionSub2 LEFT JOIN qryExpertOpinionSub1 ON (qryExpertOpinionSub2.CropYear = qryExpertOpinionSub1.CropYear) AND (qryExpertOpinionSub2.ProductMainGroupID = qryExpertOpinionSub1.ProductMainGroup) AND (qryExpertOpinionSub2.ClassID = qryExpertOpinionSub1.ClassID)) INNER JOIN tblProductMainGroups ON qryExpertOpinionSub2.ProductMainGroupID = tblProductMainGroups.ProductMainGroupID) ON tblClasses.ClassID = qryExpertOpinionSub2.ClassID
GROUP BY tblProductMainGroups.ProductMainGroup, tblClasses.Class
PIVOT qryExpertOpinionSub2.CropYear In ("Product","Class",2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025);

Open in new window

0
Comment
Question by:dlogan7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 37782412
Remove the columns "Product" and "Class" from the PIVOT IN () clause

PIVOT qryExpertOpinionSub2.CropYear In (2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025);
0
 

Author Comment

by:dlogan7
ID: 37783173
Duh..."column" heads. I've done it correctly before, just been a long time.
0
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 37783212
glad I could help.  We've all been there!  ;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question