|
-
Jun 16th, 2006, 09:59 AM
#1
[RESOLVED] Access 2000 (Report): Result Orientation
The following is the result set that I'm working with:
Code:
C6N 2.3875 2.3200 -4.0000 2.3300
C6U 2.5000 2.4375 -4.5000 2.4450
C6Z 2.6400 2.5775 -3.7500 2.5850
C7H 2.7450 2.6850 -4.2500 2.6925
C7K 2.8100 2.7625 -4.0000 2.7650
C7N 2.8850 2.8275 -3.7500 2.8350
C7Z 2.9600 2.9000 -3.2500 2.9075
C8H 3.0200 3.0000 -1.5000 3.0000
C8Z 3.1125 3.1125 .7500 3.1125
The first letter of the symbol is the commodity, the second is the year and the third is the month (H = March, Z = December, ect). The other fields are the high, lows, change and settlements.
For the report I'm making, I need the symbols in the first field to repeat horizontally on the report instead of vertically. Under each one, will be the details about that month.
The question I have is, is there a way (or a control) in access that I can use to change the orientation to display the results horizontally instead of vertically? The result I would like to see on the report is:
Code:
C6N C6U C6Z C7H ...
2.3875 2.5000 2.6400 2.6400 ...
2.3200 2.4375 2.5775 2.6850 ...
-4.0000 -4.5000 -3.7500 -4.2500 ...
2.3300 2.4450 2.5850 2.6925 ...
I plan on parsing the symbols so they're easier to read, but first I need to get over this hurdle.
Thanks in advance.
-
Jun 16th, 2006, 10:05 AM
#2
Re: Access 2000 (Report): Result Orientation
Yes, your query or report source will be a pivot query.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 16th, 2006, 10:15 AM
#3
Re: Access 2000 (Report): Result Orientation
Ok, I found PivotTable View in the designer; is that the same thing?
-
Jun 16th, 2006, 10:31 AM
#4
Re: Access 2000 (Report): Result Orientation
Ahh, ok (tables not the same thing ). I found this link:
http://www.blueclaw-db.com/accessque...ivot_query.htm
I'll try and work with it, see if I can figure it out. Thanks
-
Jun 16th, 2006, 10:31 AM
#5
Re: Access 2000 (Report): Result Orientation
For what you are looking for you will need 4 seperate pivot queries with the following synthax.
Code:
TRANSFORM Sum(YourTable.High) AS High
SELECT 'High' AS Measure
FROM YourTable
GROUP BY 'High'
PIVOT YourTable.ThreeLetterCode
Then
Code:
TRANSFORM Sum(YourTable.Low) AS Low
SELECT 'Low' AS Measure
FROM YourTable
GROUP BY 'Low'
PIVOT YourTable.ThreeLetterCode
Etc.
Once you have created a query for each measure, you can then union those resluting queries together in a fifth query.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jun 16th, 2006, 10:33 AM
#6
Re: Access 2000 (Report): Result Orientation
Thanks a ton Kenny. I'll work with it this afternoon. That looks exactly like what I need.
-
Jun 16th, 2006, 11:04 AM
#7
Re: Access 2000 (Report): Result Orientation
Ok, back to being a little lost. Here's the first query I ended up using:
Code:
TRANSFORM Sum(tblBoardPrices.curHigh) AS High
SELECT tblBoardPrices.curHigh
FROM tblBoardPrices
WHERE tblBoardPrices.strBoardSymbol LIKE "C*"
GROUP BY tblBoardPrices.curHigh
PIVOT tblBoardPrices.strBoardSymbol
Which produced:
Code:
curHigh C6N C6U C6Z C7H C7K C7N C7Z C8H C8Z
$2.37 $2.37
$2.48 $2.48
$2.63 $2.63
$2.73 $2.73
$2.80 $2.80
$2.88 $2.88
$2.95 $2.95
$3.02 $3.02
$3.15 $3.15
Is this correct so far? When I make all of them and union, is the format going to be right?
I've never messed with pivots before, so I'm kinda in a paniced daze right now. 
(Note: I'm not worried about the rounding right now, I can take care of that later.)
-
Jun 16th, 2006, 11:08 AM
#8
Re: Access 2000 (Report): Result Orientation
No, youare using the values as lables which is why you are getting the step effect.
Change your code to
Code:
TRANSFORM Sum(tblBoardPrices.curHigh) AS High
SELECT 'High' As Measure
FROM tblBoardPrices
WHERE tblBoardPrices.strBoardSymbol LIKE "C*"
GROUP BY 'High' As Measure
PIVOT tblBoardPrices.strBoardSymbol
I've just created a 'dummy' field called "Measure" to act as the row label. This should now give you a single row.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jun 16th, 2006, 11:17 AM
#9
Re: Access 2000 (Report): Result Orientation
Slight edit to the above
Code:
TRANSFORM Sum(tblBoardPrices.curHigh) AS High
SELECT 'High' As Measure
FROM tblBoardPrices
WHERE tblBoardPrices.strBoardSymbol LIKE "C*"
GROUP BY 'High'
PIVOT tblBoardPrices.strBoardSymbol
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jun 16th, 2006, 12:13 PM
#10
Re: Access 2000 (Report): Result Orientation
Ahh, ok. This works if I import the table into access. Unfortunately (and I shouldn't have left this out), I'm using ODBC connections to SQL. The table isn't local. 
If I use the same code for my ODBC connection, I get a "GROUP BY must be in SELECT" error. Is there any other way around this rather then adding a 'dummy' field in SQL?
-
Jun 16th, 2006, 12:39 PM
#11
Re: Access 2000 (Report): Result Orientation
you can always link to your SQL tables in Access so you have a linked Access table which will for the most part, act like a local access table.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 16th, 2006, 12:46 PM
#12
Re: Access 2000 (Report): Result Orientation
It is linked (using an ODBC connection), unless you're reffering to something else?
For some reason (and I think it has to do with the dummy field), it doesn't work with an ODBC connection. If I import the table from SQL, it ran perfectly. They mentioned something (I think it's what they're talking about) about this in that link i posted:
 Originally Posted by From Link
Warning about upsize to SQL Server - Access pivot query is not support. There are workarounds which are similar to the functioning of the Histogram Example (#16).
Should I be looking into this histogram or is there something I'm missing? I'm deffinitely a little dense when it comes to access.
-
Jun 16th, 2006, 12:54 PM
#13
Re: Access 2000 (Report): Result Orientation
Yes, thats what I was referring to but how many records are in this table? Is it possible to import the records to Access to isolate it from SQL?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 16th, 2006, 01:11 PM
#14
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|