The following sample code demonstrates how to print the Catalog report in the Northwind Sample Database. It changes some of the default printer settings and when the print job is completed, the code reset the printer to the default settings.
Not all printers and printer drivers support the functionality in the following sample code.
In Microsoft Office Access 2007, you only have to replace the report name "Catalog" with an available report for the sample code..
Private Sub PrintCatalogReport()
Dim rpt As Report
Application.Printer = Application.Printers(0)
DoCmd.OpenReport "Catalog", acViewPreview, , , acHidden
Set rpt = Reports!Catalog
With rpt.Printer
.BottomMargin = 720
.Copies = 2
.Duplex = acPRDPVertical 'Double sided
.PaperBin = acPRBNLargeCapacity
End With
DoCmd.OpenReport "Catalog", acViewNormal
DoCmd.Close acReport, "Catalog", acSaveNo
Set Application.Printer = Nothing
End Sub
When the print job is completed, this code will clear out the current settings and reset the global
object to the default application printer.