
Originally Posted by
djcuozz
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).