Distinguish between Print and Print Preview

  • Thread starter Thread starter Carl Rapson
  • Start date Start date
C

Carl Rapson

Is there a way to tell if a report is being printed or previewed? I would
like to be able to print an "official" report only once, then subsequent
printings would contain a watermark indicating that they were copies of the
report. But I can't find any way to distinguish between a print and a print
preview. Is there such a way?

Thanks,

Carl Rapson
 
Is there a way to tell if a report is being printed or previewed? I would
like to be able to print an "official" report only once, then subsequent
printings would contain a watermark indicating that they were copies of the
report. But I can't find any way to distinguish between a print and a print
preview. Is there such a way?

Thanks,

Carl Rapson


Here is the coding you'll need.

Add a Report Header to the Report if you do not already have one.
If you do not need a Report Header in the report, just make it's
Height 0".

Option Compare Database
Option Explicit
Dim intPreview As Integer
==========
Private Sub Report_Activate()
intPreview = -1

End Sub
==============
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview > -1 Then
MsgBox "Report is being printed"
' Place any code here to change the report if printed
End If
intPreview = intPreview + 1
End Sub
 
Here is the coding you'll need.

Add a Report Header to the Report if you do not already have one.
If you do not need a Report Header in the report, just make it's
Height 0".

Option Compare Database
Option Explicit
Dim intPreview As Integer
==========
Private Sub Report_Activate()
intPreview = -1

End Sub
==============
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview > -1 Then
MsgBox "Report is being printed"
' Place any code here to change the report if printed
End If
intPreview = intPreview + 1
End Sub

After I sent this message I remembered that if you used [Pages] in the
report you would need to modify the code.
Use the code modifications as shown here.

Option Compare Database
Option Explicit
Dim intPreview As Integer
===========
Private Sub Report_Activate()
intPreview = -1 ' If [Pages] is not used
' intPreview = -2 ' If [Pages] used

End Sub
===========
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview >= 0 Then ' If [Pages] not used
' If intPreview >= 1 Then ' If [Pages] used
MsgBox "Report is being printed"
' Place any code here to change the report if printed
End If
intPreview = intPreview + 1
End Sub
 
fredg said:
Here is the coding you'll need.

Add a Report Header to the Report if you do not already have one.
If you do not need a Report Header in the report, just make it's
Height 0".

Option Compare Database
Option Explicit
Dim intPreview As Integer
==========
Private Sub Report_Activate()
intPreview = -1

End Sub
==============
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview > -1 Then
MsgBox "Report is being printed"
' Place any code here to change the report if printed
End If
intPreview = intPreview + 1
End Sub

After I sent this message I remembered that if you used [Pages] in the
report you would need to modify the code.
Use the code modifications as shown here.

Option Compare Database
Option Explicit
Dim intPreview As Integer
===========
Private Sub Report_Activate()
intPreview = -1 ' If [Pages] is not used
' intPreview = -2 ' If [Pages] used

End Sub
===========
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview >= 0 Then ' If [Pages] not used
' If intPreview >= 1 Then ' If [Pages] used
MsgBox "Report is being printed"
' Place any code here to change the report if printed
End If
intPreview = intPreview + 1
End Sub

Thanks Fred, that's what I need. Curiously, this works even if I send the
report straight to the printer, as opposed to doing the Preview first.

Carl
 
Back
Top