Printing issues with report and selecting printer

wackywoo105

Registered User.
Local time
Yesterday, 22:50
Joined
Mar 14, 2014
Messages
203
The following is part of a piece of code to print a report. I use the code elsewhere for other reports and it works fine with the acHidden (in bold) bit in. In this case if the acHidden bit is not commented out it ignores the paper tray and tries to print a tabular of all the records in the database. Without the acHidden it works fine and prints only the one report, but flashes the report up momentarily.

Code:
Dim iSelectedPrn As String
Dim strReport As String
Dim strCrit As String
Dim rpt As Report
strCrit = "[Rec ID] = " & Me![Rec ID]

    If RecordBrother = True Then
        iSelectedPrn = "Brother MFC-J5720DW Printer"
        strReport = "Record Brother"
    Else
        iSelectedPrn = "Lexmark 5400 Series"
        strReport = "Record Lex"
    End If

    If printorpreview = acViewNormal Then
    
        DoCmd.OpenReport strReport, acViewPreview, , _
        strCrit '[B], acHidden[/B]
    
        Set rpt = Reports(strReport)
        With rpt
            Set .Printer = Application.Printers(iSelectedPrn)
            If RecordBrother = True Then .Printer.PaperBin = 258 ' which paperbin for rep if brother 258=MP Tray
        End With
        DoCmd.PrintOut
        DoCmd.Close acReport, strReport, acSaveNo
    
    Else
        
        DoCmd.OpenReport strReport, printorpreview, , _
        strCrit

    End If

Can anyone help with why it is playing up?
 
Last edited:
Can anyone help with this? I don't understand why it works fine if the report isn't hidden, but messes up if it is.
 

Users who are viewing this thread

Back
Top Bottom