Query opens over report

  • Thread starter Thread starter Al Camp
  • Start date Start date
A

Al Camp

Hello all,
I posted this question previously, but would appreciate any
further assistance anyone could give.

In Access2K I want to open a report in preview mode, and when
the user closes the report, I want to open a table for editing,
via a query.
However, the report opens in preview... and the query opens
right on top of it!

My Code:
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyTableEditQuery"

How can I prevent the query from opening over the report?

I tried placing a msgbox after the report that said "Opening
Table for Edit" hoping that would stop the query from opening,
but it too popped up over the report!
I'd prefer not to use coding on the report OnClose event,
unless... there is no other reasonable solution.

Thanks in advance,
Al Camp
 
Douglas,
If other code in the application opens that report, I wouldn't
want qryMyTableEditQuery opened in those instances. If I code
the report, then I'll have to set up some "who's calling" code
too.

If I have to code the report OnClose I will... but I just
wanted to make sure there's no other way to do it from the
calling form. Something that I may have missed perhaps...

I guess I'm also asking why I have to handle this at all. I
would think the Report Preview wouldn't relinquish control back
to the calling code until it's closed. Then all this would be a
moot issue...

Thanks for the help,
Al Camp
 
When you open a FORM in Access, using DoCmd.OpenForm, you have the option of
opening it Modal, which stops execution of the calling code until the new
form is either closed or hidden.
This sounds like the behavior you are looking for, but Access doesn't make
it available for REPORTS.
So -
one option is to redesign your report as a form. This may or may not be
feasible.
Another is to insert a loop after you call the report:
DoCmd.OpenReport "rptMyReport", acViewPreview
Do Until SysCmd(acSysCmdGetObjectState, acReport, "rptMyReport")=0
DoEvents
Loop
DoCmd.OpenQuery "qryMyTableEditQuery"

HTH
- Turtle
 
Turtle,
Thanks for the reply.
Probably won't go with a form... but I want to try your code
out! That's a bit more like what I'm looking for...

Thanks, and I'll try to get back to you on this thread...
Al Camp
 
Turtle,
Well, it only took me 5 minutes to try your code out... and it
worked like a champ. Thanks a lot... that's just the little
"workaround" I was looking for.
I owe ya one! Thanks!
Al Camp
 
Turtle,
Well, looks as though I jumped the gun a bit. In my haste, I
had the OpenQuery rem'd out when I first tested. When the report
wasnt covered up, I thought we had it. Doh!!
Problem still remains, but I'll keep working in the direction
you suggested. And as I say, I'll use the report OnClose if I
have to.
Thanks,
Al Camp
 
Back
Top