Using VBA to print Duplex in Access 2007

VBABeginner

New member
Local time
Yesterday, 23:40
Joined
Jul 22, 2010
Messages
3
I am new to this forum, and new to VBA programming in MS Access. I am trying to print a report in duplex without getting way over my head in complicated coding and not having much success. I have tried:

DoCmd.OpenReport strReport acViewPreview
DoCmd.RunCommand acCmdPrint

which works but isn't practical as users are printing entire books consisting of many reports and the dialogue box pops up for each report. I guess it could work if anyone knows how to supress it after the first time.

Alternatively, I have tried:

DoCmd.OpenReport strReport acViewDesign, , , acHidden
Application.Printer.Duplex = acPRDPVertical
DoCmd.OpenReport strReport acViewNormal

which seems like it SHOULD work, but doesn't.

I have read until I'm bleary-eyed...does anyone have any suggestions?

Thanks so much!
 
Read this article from Microsoft it deals with the Duplex printing

http://support.microsoft.com/kb/284286

The code they mention is as follows:

Note Not all printers and printer drivers support the functionality in the following sample code.

Note 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 Application.Printer object to the default application printer.
 
This is an old post, but I thought I'd add in how I was able to set my reports to print in duplex. Without any VBA.

-Open report in design view
-Click office button > print
-Click properties > change to 2 sided
-Click OK > this will print out the report
-Manually save the report, because I don't think it will prompt to save if you just close it
-Now close the report

Now printing the report any other way should have it print in duplex!
Opening the report and going to print > properties is a good way to see what the setting is currently at (I wasted a lot of paper in my tests).
 

Users who are viewing this thread

Back
Top Bottom