Visible fields on a report only when printed

G

Guest

Does anyone know how to make a text box visible only when a report is
displayed and not visible (or filled with jibberish like all "X"'s) when
printed? I tried using the format and print event on the report detail;
however, that made the field and the corresponding label invisible on the
display as well.

Basically, I have a report with a textbox named QuotedCost. It gets its
data from a table with a field that contains a quoted cost for a project. I
want this to display on the screen and not when printed (or mix it up when
printed). I was asked to keep the fields on the report so they knew I
thought about it and they could look at it on the screen, but hide it's value
when it is printed..... sometimes management makes things so difficult.....

Anyway, does anyone have a suggestion?
 
F

fredg

Does anyone know how to make a text box visible only when a report is
displayed and not visible (or filled with jibberish like all "X"'s) when
printed? I tried using the format and print event on the report detail;
however, that made the field and the corresponding label invisible on the
display as well.

Basically, I have a report with a textbox named QuotedCost. It gets its
data from a table with a field that contains a quoted cost for a project. I
want this to display on the screen and not when printed (or mix it up when
printed). I was asked to keep the fields on the report so they knew I
thought about it and they could look at it on the screen, but hide it's value
when it is printed..... sometimes management makes things so difficult.....

Anyway, does anyone have a suggestion?

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.
Create a new label, with as many x's as you wish as it's caption.
Size it the same as the current control you wish to not show when
printed.
Make the label not Visible.
Place it directly over the other control.
Name this label "lblShowX".

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
Me!lblShowX.Visible = True
Me![DataControl].Visible = False
End If
intPreview = intPreview + 1
End Sub

Change Me![DataControl] to whatever the actual name is of the control
you wish to hide. 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].
 
G

Guest

Thanks Fred,

I'll give this a try. If it don't work, I'll be back. Otherwise, I'm sure
I'll be back for something else.

Thanks Again

Don

fredg said:
Does anyone know how to make a text box visible only when a report is
displayed and not visible (or filled with jibberish like all "X"'s) when
printed? I tried using the format and print event on the report detail;
however, that made the field and the corresponding label invisible on the
display as well.

Basically, I have a report with a textbox named QuotedCost. It gets its
data from a table with a field that contains a quoted cost for a project. I
want this to display on the screen and not when printed (or mix it up when
printed). I was asked to keep the fields on the report so they knew I
thought about it and they could look at it on the screen, but hide it's value
when it is printed..... sometimes management makes things so difficult.....

Anyway, does anyone have a suggestion?

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.
Create a new label, with as many x's as you wish as it's caption.
Size it the same as the current control you wish to not show when
printed.
Make the label not Visible.
Place it directly over the other control.
Name this label "lblShowX".

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
Me!lblShowX.Visible = True
Me![DataControl].Visible = False
End If
intPreview = intPreview + 1
End Sub

Change Me![DataControl] to whatever the actual name is of the control
you wish to hide. 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

Top