Solved

Setting column headings for crosstab query causes error

Posted on 2012-03-29
3
397 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
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now