Solved

Not valid field error when using crosstab query as record source for report

Posted on 2008-06-12
4
208 Views
Last Modified: 2013-11-28
I created a report using a crosstab query as the source.  Everything works fine as long as the criteria the user selects includes data for all the columns.  What do you do if it doesn't?  How do I get around the error and just leave that column blank?
Thanks in advance.
0
Comment
Question by:BobRosas
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 21771539
You can't base a standard report on a dynamic crosstab (where the columns are not known in advance).
Either you have to fix the crosstab column headings by using the Columns property, or you have to build the report in code based on the actual columns found.
0
 
LVL 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 125 total points
ID: 21771583
Try using alias name for your fields like

SumVal: Sum(Budget)

as opposed to

Sum(Budget)            ' query will give the name SumOfBudget

Otherwise. you might have [Budget] in the control source of a text box but it expects SumOfBudget

But if you use alias name, you already know the field name and will put SumVal in the control source of the text box.

Mike
0
 

Author Comment

by:BobRosas
ID: 21772483
Thank you both for your quick responses.  I'm trying to assign column headings to see if I can get that to work but I can't even get the assigned names to work.  If I run CodeA below I get all the data I expected(the 6 columns have data for each column).  If I run CodeB, the headings show but I don't have any data under any of the 6 headings.  Any thoughts!
Thanks so much!


CodeA
TRANSFORM Count(tblMTRptAge.AgeCount) AS CountOfAgeCount
SELECT tblMTRptAge.County, tblMTRptAge.ServiceLkUpID, Sum(tblMTRptAge.Age) AS SumOfAge
FROM tblMTRptAge
GROUP BY tblMTRptAge.County, tblMTRptAge.ServiceLkUpID
PIVOT tblMTRptAge.AgeGrp;

CodeB
TRANSFORM Count(tblMTRptAge.AgeCount) AS CountOfAgeCount
SELECT tblMTRptAge.County, tblMTRptAge.ServiceLkUpID, Sum(tblMTRptAge.Age) AS SumOfAge
FROM tblMTRptAge
GROUP BY tblMTRptAge.County, tblMTRptAge.ServiceLkUpID
PIVOT tblMTRptAge.AgeGrp In ("To16","To24","To34","To44","To54","Over54");
0
 

Author Comment

by:BobRosas
ID: 21772741
Disregard above.  I thought I could name the columns anything I wanted but as soon as I named the columns to match the field names the data showed.  The report seems to be working now.  I couldn't have done it without you guys.  Thanks you both for your help.  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

919 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

20 Experts available now in Live!

Get 1:1 Help Now