Solved

Cross Tab Query, Populating All Months on Yealry Recap

Posted on 2014-12-03
3
184 Views
Last Modified: 2014-12-04
I am developing a yearly summary report for a client.  The results will always be for a single year (Jan thru Dec) of collections.

I populate a table to use as the basis of a crosstab query.  If I am populating the table for collections in January I only have results for January, populating in February there are results for Jan and Feb etc...  The crosstab work exactly as it should, the issue comes when I want to create the output report.

When creating the report from the crosstab query, it references the column heading fields to place on the report.  Since I am developing the report in November I have headings for January - November.  This will work now but in December there will be no column to place the December results.  Similarly, when I run the report next year, I initially won't have columns for the later months.

I ran into this situation once before and was given an EE solution that forced columns for all years on the crosstab result, whether or not they had data.  This way the report could be developed using fields for Jan - Dec and they would always be there.  Unfortunately that was several years ago and I don't remember the solution, nor do I have a copy of the application where I used the technique.

As a fall back I know I can create logic that makes sure to insert at least one record for each month into the table used as the basis of the crosstab query but I know there is a much cleaner solution using just the crosstab query.

Anyone know how to do this?
0
Comment
Question by:mlcktmguy
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40478745
The Column Headings property lets you specify a series of valid values.  Use the wizard to build the crosstab.  This is an example:

TRANSFORM Count(dbo_ExportDetail.[DetailID]) AS CountOfDetailID
SELECT dbo_ExportDetail.[ProcedureCode]
FROM dbo_ExportDetail
GROUP BY dbo_ExportDetail.[ProcedureCode]
PIVOT Format([FromDate],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
QBE view
0
 
LVL 1

Author Closing Comment

by:mlcktmguy
ID: 40479683
Thank you
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40480935
You're welcome:)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

920 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

13 Experts available now in Live!

Get 1:1 Help Now