I do use a similar approach to that, but in my case I test for the form being
open in the report's Open event procedure, setting the return value of its
Cancel argument to True if not, then open the form, passing the name of the
report as the OpenArgs argument, and open the report from the form, passing
the filter as WhereCondition argument. Again this allows the same form to be
used to enter the criteria for multiple reports. The end result is the same,
though your approach might have a slight edge as the report is opened once
only.
Hi Ken,
Yes, your approach seems more complex, and I'm not sure I'm seeing the
benefit. In the Open event of the report, we just run an OpenForm in
dialog mode. We don't need to check if the form is already open, as
an OpenForm will just make an already-open form visible. This has the
added advantage of "remembering" the last criteria used during this
session. We open the report only once, and we don't need OpenArgs at
all.
Avoiding opening the report twice can be a big advantage when the
report is based on a passthrough query, because Access actually
evaluates the recordset *before* the Open event, which can be a big
performance issue. We've seen a delay of a few seconds before the
criteria form is displayed. To solve it, we had to leave a "Where
1=0" clause in the passthrough when the report closes. I have a slide
on this toward the end of "Best of Both Worlds" at
http://ow.ly/M2WI.
Armen Stein
Microsoft Access MVP
www.JStreetTech.com