Report/Query question

A

Al Camp

I would like to open a report, and when the report is "closed",
I'd like to open a query.

I have this code:
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyQuery"

When the code runs, the report opens in preview, and is
immediately covered over by the query opening.

Is there a way to keep the query from running until the report is
closed. (I'd prefer not to code the opening of the query in the
Report Close event, as other functions use this report also.)

Thanks in advance,
Al Camp
 
F

fredg

I would like to open a report, and when the report is "closed",
I'd like to open a query.

I have this code:
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyQuery"

When the code runs, the report opens in preview, and is
immediately covered over by the query opening.

Is there a way to keep the query from running until the report is
closed. (I'd prefer not to code the opening of the query in the
Report Close event, as other functions use this report also.)

Thanks in advance,
Al Camp

If your version of Access supports opening a report in dialog:
DoCmd.OpenReport "ReportName", acViewPreview, , , acDialog
DoCmd.OpenQuery "QueryName"

You'll need to close the report using the Report's close (X) button.
 
A

Al Camp

Fred,
Alas, I'm using Access2K, so acDialog is not an option.
You know, I was really surprised that Access would allow the
query to run at all... until the report closed. Seems to me that
the report should maintain focus (control) of the code until it
is closed.
Well, perhaps someone else will have an idea...
Thanks for your reply.
Al Camp
 
T

tina

well, you could create a public variable, as
Public blnOpenQuery As Boolean

change
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyQuery"
to
DoCmd.OpenReport "rptMyReport", acViewPreview
blnOpenQuery = True

in the report's OnClose event, add the following code, as

If blnOpenQuery Then
blnOpenQuery = False
DoCmd.OpenQuery "qryMyQuery"
End If

when you open the report from another function, blnOpenQuery won't be True,
so the query won't open when the report closes.

hth


Al Camp said:
Fred,
Alas, I'm using Access2K, so acDialog is not an option.
You know, I was really surprised that Access would allow the
query to run at all... until the report closed. Seems to me that
the report should maintain focus (control) of the code until it
is closed.
Well, perhaps someone else will have an idea...
Thanks for your reply.
Al Camp
 
A

Al Camp

tina said:
well, you could create a public variable, as
Public blnOpenQuery As Boolean

change
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyQuery"
to
DoCmd.OpenReport "rptMyReport", acViewPreview
blnOpenQuery = True

in the report's OnClose event, add the following code, as

If blnOpenQuery Then
blnOpenQuery = False
DoCmd.OpenQuery "qryMyQuery"
End If

when you open the report from another function, blnOpenQuery won't be True,
so the query won't open when the report closes.

hth
 
A

Al Camp

Thanks Tina,
I'll give that a try, but I did want to avoid using report
code to solve the problem.
Can't believe there isn't a more "simple" solution...
I may try reposting...
Thanks again,
Al Camp


tina said:
well, you could create a public variable, as
Public blnOpenQuery As Boolean

change
DoCmd.OpenReport "rptMyReport", acViewPreview
DoCmd.OpenQuery "qryMyQuery"
to
DoCmd.OpenReport "rptMyReport", acViewPreview
blnOpenQuery = True

in the report's OnClose event, add the following code, as

If blnOpenQuery Then
blnOpenQuery = False
DoCmd.OpenQuery "qryMyQuery"
End If

when you open the report from another function, blnOpenQuery won't be True,
so the query won't open when the report closes.

hth
 
Top