Open report without printing

ClaraBarton

Registered User.
Local time
Yesterday, 19:44
Joined
Oct 14, 2019
Messages
706
@Pat Hartman
I'm trying to use Pat's label printing code. When I open the report from a form I use
Code:
DoCmd.OpenReport strReport, acViewNormal, _
                OpenArgs:=Me.Name & "|" & Skip

The report immediately starts printing and does not hit the Open code in the report.
Code:
    Private CallingForm         As String
    Dim intBlankCount           As Integer
    Dim Skip                    As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If intBlankCount < Skip Then
       Me.NextRecord = False
       Me.PrintSection = False
       intBlankCount = intBlankCount + 1
    End If
End Sub

Private Sub Report_Open(Cancel As Integer)
 Dim strFilter               As String
strFilter = Forms.frmUtility.fsubUtility.Form.Filter
    If Not IsNull(Me.OpenArgs) Then
           CallingForm = Left(OpenArgs, InStr(OpenArgs, "|") - 1)
        Skip = Mid(OpenArgs, InStr(OpenArgs, "|") + 1)
    End If
    Me.RecordSource = "qryUtility Where " & strFilter
    Me.CurrentView = 5
End Sub
 
acViewNormal selects that you open the report in "normal" view - which is equivalent to PrintPreview - and then it triggers the output of the report to go to the printer.

Use either acViewReport or acViewPreview, which does not trigger forwarding the report to the printer.
 
Then I receive a "the property is read only and cannot be set" at Me.Recordsource =...
 
To view a report and not print, I think you could use either acViewPreview or acPreview.
 

Users who are viewing this thread

Back
Top Bottom