Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Preview and Print

Status
Not open for further replies.

Netherby

Programmer
Nov 9, 2001
32
GB
Hi,

When I preview one of my reports, I would like to see a couple of extra fields that will not appear when I actually print out the report.

If possible, I'd like to avoid having two separate reports.

Is there an elegant way to do this? Something like the 'DispalyWhen' property that can be used on a form would be ideal.

Can I use the OnFormat event in the report header? If so, how can I tell whether I used acPreview or acNormal to open the report?

Thanks.

 
Have a look at the CurrentView property of the Report.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. Unfortunately the report CurrentView property is only available from Access 2007 and I'm working with 2003. Any other ideas?
 
Use the OpenArgs property to pass across a value when you open the report, you can then read this in your code and set the visible property on the field (and any headers) as applicable.

Example:

From your form:
DoCmd.OpenReport "MyReport", acViewNormal, OpenArgs:="N"

DoCmd.OpenReport "MyReport", acViewPreview, OpenArgs:="Y"

In your report module, something like:

Code:
Private Sub Report_Open
  ' Toggle header for field1 
  If Me.OpenArgs = "Y" Then
    Me.lblField1Header.Visible = True
    Me.txtField1.Visible = True
  ElseIf Me.OpenArgs = "N" Then
    Me.lblField1Header.Visible = False
    Me.txtField1.Visible = False
  End If
End Sub

John

 
I was able to do something like this with code in the report like below. The key is the Activate event.
Code:
Option Compare Database
Option Explicit
Dim booPreview As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.txtCategoryID.Visible = booPreview
End Sub

Private Sub Report_Activate()
    booPreview = True
End Sub

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    booPreview = False
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top