Solved

Preview multiple reports

Posted on 2011-02-19
8
418 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:mlcktmguy
8 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 34935147
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.
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 34944375
I made the chnage that you suggested and no erros or messages were displayed.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34955768
<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
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 34973656
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.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34974374
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
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 34999932
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.

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35000321
Again, perhaps another Expert will be willing to take this on...
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 250 total points
ID: 35003542
I have always avaided tryng to opebn multiple instances of the same report object.

I do have a solutiont hat works great.   I use the acess snap shot viewer for my print previews. I send each repor to a snapshot file (.snp) then ShellExec to open each onw. The snapshot view looks and works very similar to the print preview.

** Note: It does require the free snapshot viwer to be installed. **

I also do theg same thing using PDF's.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now