Solved

Automatically add columns to a query or report if they exist in an input table or query

Posted on 2013-01-30
4
251 Views
Last Modified: 2013-01-30
I have a crosstab query which increases in columns as a feed table is populated to include data for new periods in the year.

An example of the crosstab output is detailed below.....

Measure 01 02 03 etc (pput eriods in a year)
ABC          1   3    7
DEF           2   9   12

From the crosstab i am running a report but i want to automatically include every period as and when the crosstab adds them, is this possible?

Apologies if its not well explained as i am struggling for the right words.

Thanks
0
Comment
Question by:SweetingA
  • 2
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 38836974
Not easily, in a report.

Search EE on "dynamic crosstab report" for discussions of this concept.
0
 

Author Comment

by:SweetingA
ID: 38837032
is it easy in a query and then i can just add another step?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38837067
If your data is normalized with a Period or [SomeDate] field, which then becomes your column headers in the crosstab query, then you should not have to do anything to create the additional column in your query results.

The challenging part is displaying the output in a report.  The query should export just fine to something like Excel, but you eventually run out of page space with a report, and you then have to decide which columns to include in the report.

You could implement some form of paging in your query, which would prevent more than X# of columns per page, and this would not be too difficult, but exporting to Excel is pretty simple.
0
 

Author Closing Comment

by:SweetingA
ID: 38837374
Used a solution by GrayL which is very simple as long as you know the eventual names of all columns - simply edit the PIVOT line of the SQL.

PIVOT qry_PDM_Results_CY.Period In ("01","02","03","04","05","06","07","08","09","10","11","12");

Thanks, could have looking for days!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

825 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