multiple instances of a report

  • Thread starter Thread starter Quaxi
  • Start date Start date
Q

Quaxi

Hi!
I'm trying to generate a module which should open several instances of a
report (with different filters set) simultaneously in preview.

Thanks for any help!
 
Managing multiple report instances is messy.

To open an instance you need:
Set rpt = New Report_MyReport
and then some way to manage the rpt object until it should be released (so
it doesn't just go out of scope)

This doesn't let you use a WhereCondition like OpenReport does, but you can
set its Filter property in the Open event of the report. For some obscure
reason, this doesn't work correctly unless you include a DoEvents first. If
you don't do that, the Filter gets applied to the wrong instance of the
report.
 
Where do you put the doevents? In the open-section of the report or in the
module which is calling the report???
 
HI Hermes

We used to include DoEvents in the report's Open event to ensure the filter
was applied to the report.

However, I'm not seeing that working now.
 
hermes said:
Where do you put the doevents? In the open-section of the report or in the
module which is calling the report???


In my limited experiece with this, the DoEvents goes just
before the Set rpt = New Report_ ... statement.
 
Marshall Barton said:
In my limited experiece with this, the DoEvents goes just
before the Set rpt = New Report_ ... statement.
Now it works!
It was necessary to use two doevents; one before the set rpt=New Report_...,
and a second one before the rpt.visible=true.
This seems to be a bug in Access, because the results of the reports were
unpredictable when calling the function to open multiple instances of the
report. On the other hand, when running the code in Debug mode (SHIFT F8),
the reports opened correctly. Also, the calculated fields of the reports
contained error messages before using the second DoEvents command.

Thank you for your help!
Peter
 
Peter, I've been doing some experimenting with this over the last 24 hours,
and I am not finding consistency.

I know I have used DoEvents in the past. Don't know if its because of a
faster processor or hyperthreading, but the DoEvents does not seem to give
reliable results in all cases.

The only thing that seems bulletproof is to give up on trying to use filters
with multiple instances of reports, and reassign the RecordSource of the
report in its Open event instead. This is a bit more work, but achieves the
same result. You can assign the desired recordsource statement to a public
string variable, and read it and assign it in Report_Open.
 
Allen Browne said:
The only thing that seems bulletproof is to give up on trying to use filters
with multiple instances of reports, and reassign the RecordSource of the
report in its Open event instead. This is a bit more work, but achieves the
same result. You can assign the desired recordsource statement to a public
string variable, and read it and assign it in Report_Open.

That's what I did, too. I assigned the record Source dynamically without use
of filters. By the way, it's much faster than the use of filters. But even
in this case, I needed the DoEvents. Don't know why, but it seems working...

Greetings,
Peter
 
Allen said:
Peter, I've been doing some experimenting with this over the last 24 hours,
and I am not finding consistency.

I know I have used DoEvents in the past. Don't know if its because of a
faster processor or hyperthreading, but the DoEvents does not seem to give
reliable results in all cases.

The only thing that seems bulletproof is to give up on trying to use filters
with multiple instances of reports, and reassign the RecordSource of the
report in its Open event instead. This is a bit more work, but achieves the
same result. You can assign the desired recordsource statement to a public
string variable, and read it and assign it in Report_Open.


Interesting!

Another case of the half cooked Filter property?

And two DoEvents is a new one on me. Hmmm, wonder if it has
anything to do with how much code or what kind of code is in
the Open event???

Another entry in the "What's Going on Here" log book.
 
Back
Top