By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

Use New for multiple rept. instances conflicts w/ ControlSource on open

P: n/a
Hi all,

This is actually not an issue of mine, but one a friend of mine told me about
that I was able to confirm.

Let's say you want a highly customizable report, so you want to be able to do
things like specify the ControlSource properties of TextBox controls on the
report when it is run. The only time this works is in the Open event handler,
but that works great. So, no problem, right?

Now, say the report is called rptFoo, and you want to open multiple instances
of the report for preview, so now, instead of using DoCmd.OpenReport, you use
something like Set mrptKeepOpen1 = New Report_rptFoo. This looks like it
should work, but now the code in the report Open event handler says "You can't
set the Control Source property in print preview or after printing has
started."

As a possible work-around, I tried making a master report that embeds the
custom report as a sub-report, and opening that using the New keyword, but the
same error appears.

Does anyone know any work-arounds?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Steve, there are many problems with trying to implement multiple instances
of reports.

Is it possible that the Open event is firing twice, and that the timing
problem is with the 2nd occurance? Haven't tested: just a possibility.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:cu********************************@4ax.com...
Hi all,

This is actually not an issue of mine, but one a friend of mine told me about that I was able to confirm.

Let's say you want a highly customizable report, so you want to be able to do things like specify the ControlSource properties of TextBox controls on the report when it is run. The only time this works is in the Open event handler, but that works great. So, no problem, right?

Now, say the report is called rptFoo, and you want to open multiple instances of the report for preview, so now, instead of using DoCmd.OpenReport, you use something like Set mrptKeepOpen1 = New Report_rptFoo. This looks like it
should work, but now the code in the report Open event handler says "You can't set the Control Source property in print preview or after printing has
started."

As a possible work-around, I tried making a master report that embeds the
custom report as a sub-report, and opening that using the New keyword, but the same error appears.

Does anyone know any work-arounds?

Nov 12 '05 #2

P: n/a
Steve Jorgensen <no****@nospam.nospam> wrote in
news:cu********************************@4ax.com:
Hi all,

This is actually not an issue of mine, but one a friend of mine
told me about that I was able to confirm.

Let's say you want a highly customizable report, so you want to be
able to do things like specify the ControlSource properties of
TextBox controls on the report when it is run. The only time this
works is in the Open event handler, but that works great. So, no
problem, right?

Now, say the report is called rptFoo, and you want to open
multiple instances of the report for preview, so now, instead of
using DoCmd.OpenReport, you use something like Set mrptKeepOpen1 =
New Report_rptFoo. This looks like it should work, but now the
code in the report Open event handler says "You can't set the
Control Source property in print preview or after printing has
started."

As a possible work-around, I tried making a master report that
embeds the custom report as a sub-report, and opening that using
the New keyword, but the same error appears.

Does anyone know any work-arounds?


I've encountered this myself in the past.

The only workaround I found was to use a separate object variable
for each instance.

Perhaps you could do this with an array of type Report so you
wouldn't have to hard-code the number of openable reports?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #3

P: n/a
On Mon, 02 Feb 2004 16:59:53 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:
Steve Jorgensen <no****@nospam.nospam> wrote in
news:cu********************************@4ax.com :
Hi all,

This is actually not an issue of mine, but one a friend of mine
told me about that I was able to confirm.

Let's say you want a highly customizable report, so you want to be
able to do things like specify the ControlSource properties of
TextBox controls on the report when it is run. The only time this
works is in the Open event handler, but that works great. So, no
problem, right?

Now, say the report is called rptFoo, and you want to open
multiple instances of the report for preview, so now, instead of
using DoCmd.OpenReport, you use something like Set mrptKeepOpen1 =
New Report_rptFoo. This looks like it should work, but now the
code in the report Open event handler says "You can't set the
Control Source property in print preview or after printing has
started."

As a possible work-around, I tried making a master report that
embeds the custom report as a sub-report, and opening that using
the New keyword, but the same error appears.

Does anyone know any work-arounds?


I've encountered this myself in the past.

The only workaround I found was to use a separate object variable
for each instance.

Perhaps you could do this with an array of type Report so you
wouldn't have to hard-code the number of openable reports?


No, that's not the problem. I just used the single variable as an example for
brevity. The problem occurs the first time we try to create the first
instance of the report using New. How many instances, and where each
instances is stored seem to have no effect on the error.
Nov 12 '05 #4

P: n/a
On Mon, 2 Feb 2004 14:40:19 +0800, "Allen Browne" <Al*********@SeeSig.Invalid>
wrote:
Steve, there are many problems with trying to implement multiple instances
of reports.

Is it possible that the Open event is firing twice, and that the timing
problem is with the 2nd occurance? Haven't tested: just a possibility.


I checked that just now, and Open only fires once, so that's not it. I would
try using Initialize instead of Open, but report modules don't have that event
type.
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.