Double-sided print

ErinL

Registered User.
Local time
Today, 10:10
Joined
May 20, 2011
Messages
118
Hello everyone -

I was wondering if there is a way to automatically set a multi-page report to print double-sided through Access or VBA.

Thank you in advance. ;)
 
Yes, you can do it through VBA, if your Printer have that capability (most Laser Printers do).

Copy and Paste the following Code into a Standard Module in your Project:
Code:
Private Type str_DEVMODE
    RGB As String * 94
End Type

Private Type type_DEVMODE
    strDeviceName As String * 16
    intSpecVersion As Integer
    intDriverVersion As Integer
    intSize As Integer
    intDriverExtra As Integer
    lngFields As Long
    intOrientation As Integer
    intPaperSize As Integer
    intPaperLength As Integer
    intPaperWidth As Integer
    intScale As Integer
    intCopies As Integer
    intDefaultSource As Integer
    intPrintQuality As Integer
    intColor As Integer
    intDuplex As Integer
    intResolution As Integer
    intTTOption As Integer
    intCollate As Integer
    strFormName As String * 16
    lngPad As Long
    lngBits As Long
    lngPW As Long
    lngPH As Long
    lngDFI As Long
    lngDFr As Long
End Type

Public Sub DoubleSided(ByVal strName As String, ByVal dm_duplex as Integer)
    
    Const DM_PAPERSIZE = 9
    Dim DevString As str_DEVMODE
    Dim DM As type_DEVMODE
    Dim strDevModeExtra As String
    Dim rpt As Report

   ' Opens report in Design view.
    DoCmd.OpenReport strName, acDesign
    Set rpt = Reports(strName)

    If Not IsNull(rpt.PrtDevMode) Then
        strDevModeExtra = rpt.PrtDevMode
        DevString.RGB = strDevModeExtra
        LSet DM = DevString
        DM.lngFields = DM.lngFields Or DM.intOrientation
        'Initialize fields.
        DM.intPaperSize = DM_PAPERSIZE
       [B] If DM.intDuplex = 1 Then
            DM.intDuplex = dm_duplex
        End If[/B]

        ' Update property.
        LSet DevString = DM
        Mid(strDevModeExtra, 1, 94) = DevString.RGB
        rpt.PrtDevMode = strDevModeExtra
    End If
    DoCmd.Close acReport, strName, acSaveYes
    DoCmd.OpenReport strName, acViewPreview
    Set rpt = Nothing

End Sub

Call the DoubleSided() Function with your report name and printing type parameters from a Command Button Click Event Procedure, like the example given below:

Code:
Private Sub cmdPreview_Click()
     DoubleSided "MyReport",2
End Sub

Second parameter values:

1 - One side printing
2 - Both side printing

The Report will be opened in Print Preview. User can sent it to the default printer.


Visit the links for more details:
Network and Report Page Setup
Network and Report Page Setup-2
Network and Report Page Setup-3
 
Last edited:
That's perfect! Thank you so much! :D
 

Users who are viewing this thread

Back
Top Bottom