Solved

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

Posted on 2013-01-30
4
271 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 48

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 48

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

696 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