Solved

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

Posted on 2013-01-30
4
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

739 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