Determining Opening Mode of Report

C

Chaplain Doug

I open a report one of two ways, either to print:

DoCmd.OpenReport stDocName, acNormal

Or to preview,

DoCmd.OpenReport stDocName, acPreview

When the report is opened to print I want to prompt the
user (which I do in the OnOpen event). When the report is
opened in preview, I do not want to prompt the user. How
may I programmatically determine the mode in which the
report has been opened from within the report (OnOpen
event)? Thanks.
 
F

fredg

I open a report one of two ways, either to print:

DoCmd.OpenReport stDocName, acNormal

Or to preview,

DoCmd.OpenReport stDocName, acPreview

When the report is opened to print I want to prompt the
user (which I do in the OnOpen event). When the report is
opened in preview, I do not want to prompt the user. How
may I programmatically determine the mode in which the
report has been opened from within the report (OnOpen
event)? Thanks.

Prompt the user for what?

The Report's Activate does not fire when the report is to be printed,
only when previewed.

You can set a variable up in the Report's Declarations section,
Option Explicit
Dim intPreview as Integer

and give it a value in the Activate event

intPreview = -1

Check the variable value in the report Header Format event and move
the message prompt you now have in the Open event to the Report Header
format event.

If intPreview >= 0 Then
MsgBox "Printing message here"
End If
intPreview = intPreview + 1

The message will not appear if the report is only displayed.
It will appear when printed, and if printed while in preview.
 
C

Chaplain Doug

I am prompting the user to make sure that they put blank
card stock in the printer before printing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top