ACC1x: Using PrtDevMode Property to Set Print Setup Dialog Box

ID: Q109828


The information in this article applies to:


SUMMARY

This article describes the PrtDevMode property. While this property is documented in the Microsoft Access Distribution Kit (ADK) documentation, the information applies to the retail product as well.


MORE INFORMATION

The PrtDevMode property sets or returns the device mode information specified in the Print Setup dialog box for a datasheet, form, report, or module.

The PrtDevMode property setting is a 64-byte structure that mirrors the DEVMODE structure defined in the Microsoft Windows Software Development Kit (SDK). The PrtDevMode property has the following members:

Only drivers that are fully updated for Windows version 3.0 and later and that export the ExtDeviceMode function use the DEVMODE structure. An application can retrieve the paper sizes and names supported by a printer by calling the DeviceCapabilities() function with the DC_PAPERS, DC_PAPERSIZE, and DC_PAPERNAMES values.

Drivers can add device-specific data immediately following the DEVMODE structure.

The following example demonstrates how to use the PrtDevMode property to specify the number of copies to print for a report:

   Function SetCopies (MyReport As String, Copies As Integer)
      Dim dm As zwtDevModeStr
      Dim DevMode As zwtDeviceMode
        DoCmd Echo False
      DoCmd OpenReport MyReport, A_DESIGN
      If Not IsNull(Reports(MyReport).PrtDevMode) Then
         dm.rgb = Reports(MyReport).PrtDevMode
         LSet DevMode = dm
         DevMode.dmCopies = Copies
         Devmode.dmFields = DM_COPIES
         LSet dm = DevMode
         Reports(MyReport).PrtDevMode = dm.rgb
         DoCmd SetWarnings False
         DoCmd DoMenuItem 7, A_FILE, 2
         DoCmd Close A_REPORT, MyReport
         DoCmd SetWarnings True
      End If
      DoCmd Echo True
   End Function 



The next example demonstrates how to set the paper size for a report:

   Sub SetPaperSize (MyReport As String, MyPaperSize As Integer)
      Dim dm As zwtDevModeStr
      Dim DevMode As zwtDeviceMode
           DoCmd Echo False
      DoCmd OpenReport MyReport, A_DESIGN
      If Not IsNull(Reports(MyReport).PrtDevMode) Then
         dm.rgb = Reports(MyReport).PrtDevMode
         LSet DevMode = dm
         DevMode.dmPaperSize = MyPaperSize
         LSet dm = DevMode
         Reports(MyReport).PrtDevMode = dm.rgb
         DoCmd SetWarnings False
         DoCmd DoMenuItem 7, A_FILE, 2
         DoCmd Close A_REPORT, MyReport
         DoCmd SetWarnings True
      End If
           DoCmd Echo True
   End Sub 


REFERENCES

Microsoft Access "The Secrets of AccessWizards," pages 21-26 (NOTE: This manual is available from Microsoft Sales Information Center at 1 (800) 426-9400. It is part number 077-050-039, and costs $9.95.)


Keywords          : kbprint PtrOthr 
Version           : 1.0 1.1
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: April 2, 1999