Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Preview multiple reports

I have a single report that the user would like to preview for multiple clients.  I have run into this situation before and with the help of EE realized that to preview mulitple versions of the same report at the same time I have to create a new instance of the report for each preview.

The logic looks like this now:

Dim reportInstance As String  ' done so mulitple yield reports can be shown
'
reportInstance = getNextYieldReportInstance()
'
DoCmd.OpenReport reportInstance, acViewPreview, , , , oArgs

The instance is created using the routine in the code window.

I also have a routine to clean up all of the temorary instances

I am working on a similar conept for another client and handled it exactly the same way but it's not working.  When the logic that generates the multiple previews is complete only the last report generates is previewed.  I verified that all of the instance are being created correctly and you can see the correct previews on the screen as the report for each cuatomer is generated.  HOwever, at conclusion only the last report is avaialble for preview.

One difference between the reports is that the firts report I tried this with had no subreports and the new one that isn't working has two subreports.  I wanted to test this and can easily generate new instances of the subreports as I generate the new instance of the main report.  However, I don't know how to use code to revise the the new instance of the main report to use the new instances of the subreports ratehr than the originals.

I would appreciate any code showig how to revise the new isnatnce of the main report to use the two new insatnces of the supreports.  Or another suggestion as to how to preview multiple reports (with a subreport).

The main report name is
'wkRecap Rpt_Driver' and subreports are:
'subbrptWkRecp_1' and 'subReportWkRecap_2'

The reprot names in the coding example are from my old application, not the new one.
Public Function getNextYieldReportInstance() As String
'
DoCmd.SetWarnings False
gNumYieldReports = gNumYieldReports + 1
'
Dim newName As String
'
newName = cTempReportPrefix & "rptYieldReport" & Trim(Str(gNumYieldReports))
'
DoCmd.CopyObject , newName, acReport, "rptYieldReport"
'
getNextYieldReportInstance = newName
'
End Function

Open in new window

Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Change this line to TRUE and see what kind of messages you are generating.
DoCmd.SetWarnings False

The messages you are suppressing may yield some clues as to what you have going on.
Avatar of mlcktmguy

ASKER

I made the chnage that you suggested and no erros or messages were displayed.
Avatar of Jeffrey Coachman
<One difference between the reports is that the firts report I tried this with had no subreports and the new one that isn't working has two subreports.>
Then this would seem to be the key.

Remember that you only created multiple instances of the Main form originally.
Although a subform is embedded into a main report, it is not technically a "part" of the Main report.

So in this case you would have to create an instance of the subreport as well.

I can see this becoming messy as you would have to keep track of the subforms and how they are referenced as well.
This is the reason why (as "cool" as this technique seems) viewing multiple instances of a report/form is not commonly used.
Besides, (if you are doing this the way I suspect), creating new report objects on the fly, will boat the DB.
Do you have code to clean up the temp reports?

Just curious, what is the reason why your user can't view one report at a time?

JeffCoachman
The user wants to be able to click back and forth between the reports, reviewing the information.  If it looks good they want ot print them, otherwise they will rework the input.

I haven't gotten any means of presenting multiple versions of these reports together, even though it worked with the reports that didn't have sub reports.

As a work around I present each report using acdialog, when they close the report they are asked if they want to see another.

This isn't really what they want but it does enable them to see all versions (one at a time) before printing.

I dodn't have any problem creating multiple instances of the main reports and sub reports but have no idea how to link the new instances og the main report with the new instances of the sub reports.

As I mnetioned in my original post "I also have a routine to clean up all of the temorary instances" so the MDB does not get bloated.  I also have the 'compact on close' option checked so the MDB compacts every time they close it.
Again, opening multiple instances of a From/Report is not commonly done, opening multiple instances of reports with subreports is rarer still.
Perhaps there is an Expert willing to help you with the specifics of doing this.
Please click the "Request Attention" link and ask that an alert be sent out for this Q.

Seeing multiple Report instances might be OK for a handful of Clients.
But how are you limiting this?, ...What if you have hundreds of Clients?!

JeffCoachman
I undertsand that this is not a common requirement but it is what my clients have asked for.  I try to accomodate my client's requests or offer acceptable alternatives.

Each user has a copy of the procedures on thier local machine (C: drive) and that is what they execute.  The reports are created in each of their local copies.  The number of users doing this would be under 10 at any one time but they are all independant of each other.

Only the data is on the network server, each of the local copies of the Procedures (Forms, queries, reports, etc..) are linked ot it.

Again, perhaps another Expert will be willing to take this on...
ASKER CERTIFIED SOLUTION
Avatar of Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial