Solved

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

Posted on 2008-06-12
4
207 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

758 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