Microsoft KB Archive/109828

{|
 * width="100%"|

ACC1x: Using PrtDevMode Property to Set Print Setup Dialog Box

 * }

Q109828

-

The information in this article applies to:


 * Microsoft Access versions 1.0, 1.1

-

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:

 DeviceName: A 32-character string that specifies the name of the device the driver supports--for example, "HP LaserJet IIISi" in the case of the Hewlett-Packard LaserJet IIISi. Each driver has a unique string. SpecVersion: An integer that specifies the version number of the DEVMODE structure in the SDK. For Microsoft Windows version 3.1, this value should be 0x30A. DriverVersion: An integer that specifies the printer driver version number assigned by the printer driver developer. Size: An integer that specifies the size, in bytes, of the DEVMODE structure. (This value does not include the optional dmDriverData member for device-specific data, which can follow this structure.) If an application manipulates only the driver-independent portion of the data, you can use this member to find out the length of this structure without having to account for different versions. DriverExtra: An integer that specifies the size, in bytes, of the optional dmDriverData member for device-specific data, which can follow this structure. If an application does not use device-specific information, you should set this member to 0.  Fields: A Long value that specifies which of the remaining members in the DEVMODE structure have been initialized. It can be any combination (or it can be none) of the following values:

     Constant         Value --     DM_ORIENTATION   &H0000001 DM_PAPERSIZE    &H0000002 DM_PAPERLENGTH  &H0000004 DM_PAPERWIDTH   &H0000008 DM_SCALE        &H0000010 DM_COPIES       &H0000100 DM_DEFAULTSOURCE &H0000200 DM_PRINTQUALITY &H0000400 DM_COLOR        &H0000800 DM_DUPLEX       &H0001000 DM_YRESOLUTION  &H0002000 DM_TTOPTION     &H0004000

A printer driver supports only those members that are appropriate for the printer technology.  Orientation: An integer that specifies the orientation of the paper. It can be either 1 (portrait) or 2 (landscape).  PaperSize: An integer that specifies the size of the paper to print on. You can set this member to 0 if the length and width of the paper are specified by the PaperLength and PaperWidth members, respectively. Otherwise, the PaperSize member can be set to one of the following predefined values:

<pre class="FIXEDTEXT">     Value   Meaning ---     1       Letter (8.5 x 11 in.) 2      Letter Small (8.5 x 11 in.) 3      Tabloid (11 x 17 in.) 4      Ledger (17 x 11 in.) 5      Legal (8.5 x 14 in.) 6      Statement (5.5 x 8.5 in.) 7      Executive (7.25 x 10.5 in.) 8      A3 (297 x 420 mm) 9      A4 (210 x 297 mm) 10     A4 Small (210 x 297 mm) 11     A5 (148 x 210 mm) 12     B4 (250 x 354) 13     B5 (182 x 257 mm) 14     Folio (8.5 x 13 in.) 15     Quarto (215 x 275 mm) 16     11 x 17 in. 18     Note (8.5 x 11 in.) 19     Envelope #9 (3.875 x 8.875 in.) 20     Envelope #10 (4.125 x 9.5 in.) 21     Envelope #11 (4.5 x 10.375 in.) 22     Envelope #12 (4.75 x 11 in.) 23     Envelope #14 (5 x 11.5 in.) 24     C size sheet (17 x 22 in.) 25     D size sheet (22 x 34 in.) 26     E size sheet (34 x 44 in.) 27     Envelope DL (110 x 220 mm) 28     Envelope C5 (162 x 229 mm) 29     Envelope C3 (324 x 458 mm) 30     Envelope C4 (229 x 324 mm) 31     Envelope C6 (114 x 162 mm) 32     Envelope C65 (114 x 229 mm) 33     Envelope B4 (250 x 353 mm) 34     Envelope B5 (176 x 250 mm      35      Envelope B6 (176 x 125 mm)      36      Envelope (110 x 230 mm)      37      Envelope Monarch (3.875 x 7.5 in.)      38      6-3/4 Envelope (3.625 x 6.5 in.)      39      US Std Fanfold (14.875 x 11 in.)      40      German Std Fanfold (8.5 x 12 in.)      41      German Legal Fanfold (8.5 x 13 in.)      256     User-defined

</li> PaperLength: An integer that specifies the paper length in tenths of a millimeter. This member overrides the paper length specified by the PaperSize member, either for custom paper sizes or for devices such as dot-matrix printers that can print on a variety of paper sizes.</li> PaperWidth: An integer that specifies the paper width in tenths of a millimeter. This member overrides the paper width specified by the PaperSize member.</li> Scale: An integer that specifies the factor by which the printed output is to be scaled. The apparent page size is scaled from the physical page size by a factor of Scale/100. For example, a letter-size paper with a Scale value of 50 contains as much data as a page measuring 17 by 22 inches, because the output text and graphics are half their original height and width.</li> Copies: An integer that specifies the number of copies printed if the printing device supports multiple-page copies.</li>  DefaultSource: An integer that specifies the default bin from which the paper is fed. This member can be one of the following values:

<pre class="FIXEDTEXT">     Value   Meaning ---     1       Upper or only one bin 2      Lower bin 3      Middle bin 4      Manual bin 5      Envelope bin 6      Envelope manual bin 7      Automatic bin 8      Tractor bin 9      Small-format bin 10     Large-format bin 11     Large-capacity bin 14     Cassette bin 256    Device-specific bins start here

</li>  PrintQuality: The printer resolution. Following are the four predefined device-independent values:

<pre class="FIXEDTEXT">     Value   Meaning -     -4      High resolution -3     Medium resolution -2     Low resolution -1     Draft resolution

</li>  Color: An integer that defines whether a color printer is to render color or monochrome output. Possible values are:

<pre class="FIXEDTEXT">     Value   Meaning --     1       Color 2      Monochrome

</li>  Duplex: An integer. For a printer capable of duplex printing, specifies whether the output is printed on both sides of the paper. This member can be set to one of the following values:

<pre class="FIXEDTEXT">     Value   Meaning --     1       Simplex 2      Horizontal 3      Vertical

</li></ul>

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:

<pre class="CODESAMP">  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:

<pre class="CODESAMP">  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