Unanswered: Create a Report based on an existing report
I have created a Report with a graph also on it, and want the user to push a button and view a report just like that one, but viewing a different set of records - the listing would be different as would the graph.
I created a standard 'template' query and can create other queries based on that. Fine.
The problem is with the Report.
I thought the CreateReport() function created a report based on an existing report (I was going to use all the controls, the graph etc, just repoint them).
Then I found that CreateReport() only creates a blank report and I would have to create all the many controls.
I started to try to instantiate an existing report, etc, but didnt make much much progress.
Does anybody know if it possible for me to view an existing Report, then effectively do a SaveAS, and then alter the recordsource etc on that new Report ??
You dont need to do a 'Save As' to change the row source (you may not even need to change the row source). Do you need to see this report on screen, print it, email it, and/or save it as a file? Is the data behind the report actually going to change or just the criteria of that data? I don't think that you really want/need several report objects that are identical other than the data source.
The only thing that will change between reports is the criteria (the WHERE clause). However the user may probably choose to view several of them on screen at the same time. Users may choose to save or print as well.
I believe I need different 'instantiated' reports to both handle multiple displays on screen and to allow different queries to be written with different WHERE clauses ... some queries will look for a single category, some will use
" IN ('a', 'b', 'c'....)", and then to allow these queries to be plugged into the report and the graph.
If this report is being opened by a button you can change the filter based on user input. This would allow for the user to do everything you need except viewing several on screen at the same time.
DoCmd.CopyObject will allow you to create copies of the report, but doing this has drawbacks.
Each user will need thier own front end to be able to create the reports
Even if you delete the reports when the user is done, the db will bloat
Can you use a form that allows the user to change the filter for on screen viewing or do your users need to see a side-by-side comparison?
Thanks very much, Docmd.CopyObject sounds useful. User WILL want to side-by-side comparisons. I shall have to test it out tho' as the few users who will be using this will be using the same version on the server (but if I have copied Report to a new name hopefully that will be OK).
As for bloating, working with MS Access we have to have regular 'maintenance' (compacting) sessions so that shouldnt be a problem.