MS Access Print Report using VBA

前端 未结 3 839
梦毁少年i
梦毁少年i 2021-01-16 04:00

I have a very VBA intensive report. When I preview it everything is great but when I print it after previewing things go wacky. I have spent many hours narrowing down the po

3条回答
  •  佛祖请我去吃肉
    2021-01-16 04:43

    One solution is to set the printer options in the design of the report, save those changes and the print it. The downside is that this will tie the report to a specific printer unless you go into the design and change it.

    DoCmd.OpenReport "ReportName", acViewDesign, Null, Null, acHidden
    
    Dim oRpt As Report
    Set oRpt = Reports(0)
    oRpt.UseDefaultPrinter = False
    oRpt.Printer = Application.Printers("printer name")
    
    With oRpt.Printer
        .PaperBin = acPRBNAuto
        .PaperSize = acPRPSLetter
        .Copies = 1
        .PrintQuality = acPRPQMedium
    End With
    
    DoCmd.Close acReport, "ReportName", acSaveYes
    DoCmd.OpenReport "ReportName", acViewNormal
    
    Set oRpt = Nothing
    

提交回复
热议问题