473,505 Members | 13,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a report with a crosstab query.

33 New Member
Hi there,

A customer has asked me to create a report based on a cross-tab query. The data base schema is attached below.

The query must contain the following

ScrapCollection.regNum,
ScrapCollection.PTEtotal,
ScrapTireType.description (As the Pivot)
ScraptCollectionTireType.amount (as a sum aggregate for each description)

This is the query I have at the moment

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Forms]![AuditTotal]![start_Date] DateTime, [Forms]![AuditTotal]![end_Date] DateTime;
  2. TRANSFORM Sum(ScrapCollectionTireType.amount) AS SumOfamount
  3. SELECT ScrapCollection.regNum, ScrapCollection.PTEtotal
  4. FROM ScrapCollection INNER JOIN (ScrapTireType INNER JOIN ScrapCollectionTireType ON (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID) AND (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID)) ON ScrapCollection.scrapCollectionID = ScrapCollectionTireType.scrapCollectionID
  5. WHERE (((ScrapCollection.date2) Between [Forms]![AuditTotal]![start_Date] And [Forms]![AuditTotal]![end_Date]))
  6. GROUP BY ScrapCollection.regNum, ScrapCollection.PTEtotal
  7. PIVOT ScrapTireType.description;
  8.  
But it is wrong. I only want the data grouped by regNum. But Access will not let me do the following...

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Forms]![AuditTotal]![start_Date] DateTime, [Forms]![AuditTotal]![end_Date] DateTime;
  2. TRANSFORM Sum(ScrapCollectionTireType.amount) AS SumOfamount
  3. SELECT ScrapCollection.regNum, ScrapCollection.PTEtotal
  4. FROM ScrapCollection INNER JOIN (ScrapTireType INNER JOIN ScrapCollectionTireType ON (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID) AND (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID)) ON ScrapCollection.scrapCollectionID = ScrapCollectionTireType.scrapCollectionID
  5. WHERE (((ScrapCollection.date2) Between [Forms]![AuditTotal]![start_Date] And [Forms]![AuditTotal]![end_Date]))
  6. GROUP BY ScrapCollection.regNum
  7. PIVOT ScrapTireType.description;
  8.  

Any help will be greatly appreciated.

Thank you
Attached Images
File Type: jpg Relationships.jpg (31.2 KB, 263 views)
Jul 11 '12 #1
1 1364
Rabbit
12,516 Recognized Expert Moderator MVP
Take out PTETotal. You can't have a non-grouped, non-aggregated field in a pivot.
Jul 12 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
7538
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
10
1640
by: pw | last post by:
Hi, Is that possible if the crosstab query is dynamic? Doesn't seem so as I have to specify the control source for the text boxes and the number of columns may change, along with their field...
1
2285
by: Steve | last post by:
I have looked through the newsgroup for an answer to this but haven't been able to find anything resembling my situation. What I want to do is relatively simple, I think. I have a crosstab...
4
2080
by: No Spam | last post by:
Dear Access 2000 users, I have a crosstab query that puts together certain information perfectly. It has a criteria that is based on a form that limits how many columns are returned based on...
2
1423
by: Sherman H. | last post by:
How to set the blank cell to 0 when a crosstab query is created? Thanks.
15
4385
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
3
3402
by: Bryan | last post by:
I've been looking over this newsgroup, but I can't find an answer to my problem. I see that a few others have posted this issue over the years, but none of them got a response. I'll give it...
2
2528
by: scott.k.fraley | last post by:
....and the SELECT thats trying to pull from said Query doesn't like it one bit! ;) I'm working on this project (in Access 2002) and there is a report who's RecordSource is the following...
6
4428
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor...
2
396
by: jason.teen | last post by:
Hi All, I am having trouble creating a crosstab query. In my original data I have two columns, One called "Categorized" and one called "Mapped' in which those columns can hold values of "true"...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.