Results 1 to 5 of 5
  1. #1
    djcuozz is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2017
    Posts
    2

    One Report that can acccess multiple tables

    I would like to use one report that based off user preference can be populated by more than one table at a time. For example I have tables A, B, & C. If the user chooses table A through a macro, the report gets populated with information from table A. If the user picks table C, the report gets populated with information from table C.
    The way I have it now, I have a report for each table making it cumbersome when I need to update the report.

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi Welcome to the Forum

    Can you upload a screenshot of your Relationship Window?

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    As long as the fields are the same, just change the source of the report.
    That then begs the question why do you have 3 tables with same fields?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Quote Originally Posted by djcuozz View Post
    I would like to use one report that based off user preference can be populated by more than one table at a time. For example I have tables A, B, & C. If the user chooses table A through a macro, the report gets populated with information from table A. If the user picks table C, the report gets populated with information from table C.
    The way I have it now, I have a report for each table making it cumbersome when I need to update the report.
    Put all the records from tables A, B, and C in the same table. Include a column that indicates what table each came from. Then just open the report and pass a filter to it.

    Code:
    SELECT 'A' AS Source, col1, col2, col3
    FROM TableA
    UNION ALL
    SELECT 'B' AS Source, col1, col2, col3
    FROM TableB
    UNION ALL
    SELECT 'C' AS Source, col1, col2, col3
    FROM TableC
    Then when you open your report, you can do something like (aircode warning)

    Code:
    DoCmd.OpenReport "MyReport","[Source] = '" & Me.cboPickASource & "'";
    (Yeah, I butchered it a bit, but the basic idea is let the user choose which "table" the data came from, then pass that as a filter when you open the report).

  5. #5
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    wonder why you have 3 table with same layout to print.
    merge the tables to 1 table with extra column to identify the 3 tables, then u only print the desired table

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Report with multiple tables
    By fede in forum Reports
    Replies: 3
    Last Post: 05-12-2016, 12:52 PM
  2. Replies: 1
    Last Post: 06-09-2014, 02:04 PM
  3. Replies: 1
    Last Post: 04-12-2013, 03:03 PM
  4. Replies: 4
    Last Post: 01-05-2013, 02:32 PM
  5. How do you(Acccess to Adobe in VBA)
    By Madmax in forum Access
    Replies: 10
    Last Post: 06-28-2012, 04:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums