+ Reply to Thread
Results 1 to 12 of 12

Quickly Change Report Data Source

  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Unhappy Quickly Change Report Data Source

    Hi all,

    I have a master access file that has several excel tables linked into it. Each excel file is for a different project but the types of data are all the same. I create a query for each excel linked file and use that in my reports.

    I have about 6 different reports and so far i've been creating new reports for every project. However... it is beginning to be a lot having 6x reports for 10+ projects and any time I need to make a change to the format it becomes a huge time sink.


    Is there some VBA code that I can use to quickly change the data source of a report from one query to another?

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Quickly Change Report Data Source

    Yeah it is possible as I have done exactly this in the past, but I havent touched access in a few years (I have tried to convert over to powerpivot) so I can't offer exact help, other than it IS possible with VBA.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Quickly Change Report Data Source

    Does anyone know how I could achieve this?

  4. #4
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Quickly Change Report Data Source

    Bump /10char

  5. #5
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Quickly Change Report Data Source

    I would attempt to help you but I don't have excel 2003 and I don't know if the reference libraries are the same, so even if I figured it out with my version, it might not translate perfectly.

    Did you try recording a macro then making that code dynamic?

  6. #6
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Quickly Change Report Data Source

    Can you record macros in access?

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Quickly Change Report Data Source

    It would certainly be easier if you did not have a different table for each project. This is counter to normalization of data for RDBMS. Consider changing your data source to not have this type setup as it will continue to haunt you as your project expands. You would be better served to have the project name as one of the fields in your table and then pull data in your query based upon the project. You then need only 6 queries for all your reports.

    For a quick tutorial on how the Fundamentals of Database design, look at this link

    http://sbuweb.tcu.edu/bjones/20263/A...sDB_Design.pdf
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  8. #8
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Quickly Change Report Data Source

    Quote Originally Posted by alansidman View Post
    It would certainly be easier if you did not have a different table for each project. This is counter to normalization of data for RDBMS. Consider changing your data source to not have this type setup as it will continue to haunt you as your project expands. You would be better served to have the project name as one of the fields in your table and then pull data in your query based upon the project. You then need only 6 queries for all your reports.

    For a quick tutorial on how the Fundamentals of Database design, look at this link

    http://sbuweb.tcu.edu/bjones/20263/A...sDB_Design.pdf
    I wish that were an option. Unfortunately the excel files already exist as a company standard and because of the way it works, we wouldn't be able to combine all projects into 1 excel file.

    Surely there has to be a a quick way to change the query that the report uses as a data source.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Quickly Change Report Data Source

    Ok, since normalization is not an option, then I propose the following to simulate normalization:

    Create a Union Query to join all the tables. Then use this Union Query as the record source for your reports, changing up the criteria for each report as needed.

  10. #10
    Registered User
    Join Date
    07-27-2009
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Quickly Change Report Data Source

    okay. I did some research and got a union query. So, now I have 2 tables combined into 1.

    There is no column in my tables for "project name" though, so I dont know how to differentiate which data came from which table. Is there a way to add a parameter to the query that shows the table that each record came from?

  11. #11
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Quickly Change Report Data Source

    Sorry I cant help much, I would do this differently.
    I would use Powerpivot, a free Microsoft Addin, to link to the access tables then join to one table and pivot on that.

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Quickly Change Report Data Source

    For each table, create a query and add a new field in the QBE. In the field name for the new field, type: Table:"TableName", where TableName is the actual table name.
    Once you have created this query for each table, then join each of these queries in a Union Query.

    Look at this video and at the around the five minute mark, he shows how to easily build the Union Query.

    http://www.datapigtechnologies.com/f...nionquery.html

    See attached example
    Attached Files Attached Files
    Last edited by alansidman; 03-31-2015 at 09:28 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pivot report filter no longer alphabetical after source data change
    By Platinum3x in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-10-2013, 04:15 AM
  2. Change source data Macro (macro) in report template
    By andygeb in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-14-2010, 11:14 PM
  3. Replies: 0
    Last Post: 08-25-2009, 09:37 PM
  4. Excel 2007 - How do I quickly update a chart using Source data?
    By SWODoug in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-12-2006, 04:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1