PrtDevMode Property

Applies To

Form, Query, Report, Table.

Description

You can use the PrtDevMode property to set or return printing device mode information specified for a form, report, or module in the Print Setup dialog box.

Note It is strongly recommended that you consult the Win32® Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevMode property applies only to tables and queries in Datasheet view and reports and forms.

Setting

The PrtDevMode property setting is a 94-byte structure that mirrors the DEVMODE structure defined in the Win32 Software Development Kit. For complete information on the PrtDevMode property members, consult the Win32 Software Development Kit.

The PrtDevMode property uses the following members.

Member

Description

DeviceName

A 32-character string that specifies the name of the device the driver supports — for example, “HP LaserJet IIISi” if the Hewlett-Packard® LaserJet® IIISi is the specified printer. Each printer driver has a unique string.

SpecVersion

An Integer that specifies the version number of the DEVMODE structure in the Win32 Software Development Kit.

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 doesn’t 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.


Member

Description

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 doesn’t use device-specific information, you 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 of specific constants or none of them. For available constants, see the Fields member constants.

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, you can set the PaperSize member to a predefined value. For available values, see the PaperSize member values.

PaperLength

An Integer that specifies the paper length in units of 1/10 of a millimeter. This member overrides the paper length specified by the PaperSize member for custom paper sizes or for devices such as dot-matrix printers that can print on a variety of paper sizes.

PaperWidth

An Integer that specifies the paper width in units of 1/10 of a millimeter. This member overrides the paper width specified by the PaperSize member.

Scale

An Integer that specifies the factor by which the printed output will be scaled. The apparent page size is scaled from the physical page size by a factor of Scale/100. For example, a piece of paper measuring 8.5 by 11 inches (letter-size) with a Scale value of 50 would contain as much data as a page measuring 17 by 22 inches because the output text and graphics would be half their original height and width.

Copies

An Integer that specifies the number of copies printed if the printing device supports multiple-page copies.

DefaultSource

An Integer that specifies the default bin from which the paper is fed. For available values, see the DefaultSource member values.

PrintQuality

An Integer that specifies the printer resolution. See the PrintQuality member values of appropriate device-independent values.


Member

Description

Color

An Integer. For a color printer, specifies whether the output is printed in color. For available values, see the Color member values.

Duplex

An Integer. For a printer capable of duplex printing, specifies whether the output is printed on both sides of the paper. For available values, see the Duplex member values.

YResolution

An Integer that specifies the y-resolution of the printer in dots per inch (dpi). If the printer initializes this member, the PrintQuality member specifies the x-resolution of the printer in dpi.

TTOption

An Integer that specifies how TrueType fonts will be printed. For available values, see the TTOption member values.

Collate

An Integer that specifies whether collation should be used when printing multiple copies. Using uncollated copies provides faster, more efficient output, since the data is sent to the printer just once.

FormName

A 16-character string that specifies the name of the form to use; for example, “Letter” or “Legal”.

Pad

A Long Integer value.

Bits

A Long value that specifies in bits per pixel the color resolution of the display device.

PW

A Long value that specifies the width, in pixels, of the visible device surface.

PH

A Long value that specifies the height, in pixels, of the visible device surface.

DFI

A Long value that specifies the device’s display mode.

DFR

A Long value that specifies the frequency, in hertz (cycles per second), of the display device in a particular mode.


You can set the PrtDevMode property using a macro or an event procedure.

This property setting is read/write in Design view and read-only in other views.

Caution Printer drivers can add device-specific data immediately following the DEVMODE structure. It is important that information that may be contained after the first 94 bytes not be overwritten.

Remarks

Only printer drivers 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.

Before setting the value of the dmTTOption member, applications should find out how a printer driver can use TrueType fonts by calling the DeviceCapabilities function using the DC_TRUETYPE value.

Constants for the Fields Member

A printer driver supports only those members that are appropriate for the printer technology.

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

DM_COLLATE

&H0008000

DM_FORMNAME

&H0010000


Values for the PaperSize Member

Value

Paper size

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.25 x 11 in.)

23

Envelope #14 (5 x 11.5 in.)

24

C size sheet

25

D size sheet

26

E size sheet

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)


Value

Paper size

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


Values for the DefaultSource Member

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


Values for the PrintQuality Member

Value

Resolution

-4

High

-3

Medium

-2

Low

-1

Draft


Values for the Color Member

Value

Meaning

1

Color

2

Monochrome


Values for the Duplex Member

Value

Meaning

1

Simplex

2

Horizontal

3

Vertical


Values for the TTOption Member

Value

Meaning

1

Print TrueType fonts as graphics. This is the default for dot-matrix printers.

2

Download TrueType fonts as soft fonts. This is the default for Hewlett-Packard printers that use Printer Control Language (PCL).

3

Substitute device fonts for TrueType fonts. This is the default for PostScript printers.


See Also

PrtDevNames Property, PrtMip Property.

Example

The following example uses the PrtDevMode property to check the user-defined page size for a report.


Type str_DEVMODE
    RGB As String * 94Type
type_DEVMODE
    dmDeviceName As String * 16
    dmSpecVersion As Integer
    dmDriverVersion As Integer
    dmSize As Integer
    dmDriverExtra As Integer
    dmFields As Long
    dmOrientation As Integer
    dmPaperSize As Integer
    dmPaperLength As Integer
    dmPaperWidth As Integer
    dmScale As Integer
    dmCopies As Integer
    dmDefaultSource As Integer
    dmPrintQuality As Integer
    dmColor As Integer
    dmDuplex As Integer
    dmResolution As Integer
    dmTTOption As Integer
    dmCollate As Integer
    dmFormName As String * 16
    dmPad As Long
    dmBits As Long
    dmPW As Long
    dmPH As Long
    dmDFI As Long
    dmDFr As LongType
CheckCustomPage(rptName As String)
    Dim DevString As str_DEVMODE
    Dim DM As type_DEVMODE
    Dim DevModeExtra As String
    Dim rpt As Report
    Dim response
    ' Opens report in Design view.
    DoCmd.OpenReport rptName, acDesign
    Set rpt = Reports(rptName)
    If Not IsNull(rpt.PrtDevMode) Then
        DevModeExtra = rpt.PrtDevMode  ' Gets current DEVMODE structure.
        DevString.RGB = DevModeExtra
        LSet DM = DevString
        If DM.dmPaperSize = 256 Then
            ' Display user-defined size.
            response = MsgBox("The current Custom Page Size is " _
                & DM.dmPaperWidth / 254 & " in wide by " _
                & DM.dmPaperLength / 254 _
                & " in long. Do you want to change the settings?", 4)
        Else
            ' Currently not user-defined.
            response = MsgBox("The report does not have a custom" _
                & " page. Do you want to define one?", 4)
        End If
        If response = 6 Then
            ' User wants to change settings.
            ' Initialize fields.
            DM.dmFields = DM.dmFields Or DM_PAPERSIZE _
                Or DM_PAPERLENGTH Or DM_PAPERWIDTH
            DM.dmPaperSize = 256                    ' Set custom page.
            ' Prompt for length and width.
            DM.dmPaperLength = InputBox("Please enter Page Length" _
                & " in inches") * 254
            DM.dmPaperWidth = InputBox("Please enter Page Width" _
                & " in inches") * 254
            LSet DevString = DM                    ' Update property.
            Mid$(DevModeExtra, 1, 94) = DevString.RGB
            rpt.PrtDevMode = DevModeExtra
        End If
    End IfSub

The following example shows how to change the orientation of the report. This example will switch the orientation from portrait to landscape or landscape to portrait depending on the report’s current orientation.


Sub SwitchOrient(rptName As String)
    Const DM_PORTRAIT = 1
    Const DM_LANDSCAPE = 2
    Dim DevString As str_DEVMODE
    Dim DM As type_DEVMODE
    Dim DevModeExtra As String
    Dim rpt As Report
    DoCmd.OpenReport rptName, acDesign    ' Opens report in Design view.
    Set rpt = Reports(rptName)
    If Not IsNull(rpt.PrtDevMode) Then
        DevModeExtra = rpt.PrtDevMode
        DevString.RGB = DevModeExtra
        LSet DM = DevString
        DM.dmFields = DM.dmFields Or DM_ORIENTATION ' Initialize fields.
        If DM.dmOrientation = DM_PORTRAIT Then
            DM.dmOrientation = DM_LANDSCAPE
        Else
            DM.dmOrientation = DM_PORTRAIT
        End If
        LSet DevString = DM                ' Update property.
        Mid$(DevModeExtra, 1, 94) = DevString.RGB
        rpt.PrtDevMode = DevModeExtra
    End IfSub