Solved

Setting column headings for crosstab query causes error

Posted on 2012-03-29
3
401 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 47

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 47

Expert Comment

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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

734 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