Determine if report is in display mode

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

Is there a way to determine if a specific report is being displaye or
is actually printing?

I would like to change a text string value content based upon the
currrent state to the report.
 
Is there a way to determine if a specific report is being displaye or
is actually printing?

I would like to change a text string value content based upon the
currrent state to the report.

You can take advantage of the fact that the Report Activate event only
fires when the Report is previewed.

Here is how to go about it.

In the Code Declarations section of the Report, write:

Option Compare Database
Option Explicit
Dim intPreview as Integer
===============

Then code the Report Activate event (using intPreview = -1 or -2,
depending upon if you are computing [Pages] in the report):

Private Sub Report_Activate()
' intPreview = -1 ' If [Pages] IS NOT used
intPreview = -2 ' If [Pages] IS used

End Sub
===========
Then code the ReportHeader Format event:

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
' If intPreview >= 0 Then ' If [Pages] IS NOT used
If intPreview >= 1 Then ' If [Pages] IS used
'You can change a label's caption or set the value of an unbound
text control here.
End If
intPreview = intPreview + 1
End Sub
==========
Remember to enter the correct value for intPreview
in the Activate as well as the Header Format events, depending upon
whether or not your report is computing [Pages], i.e. = "Page " &
[Page] & " of " & [Pages].
 

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

Back
Top