Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Thanked 0 Times in 0 Posts

    Print form with graphics (97 SR-2)

    I have taken an image of a paper based (A4) form and placed this on an Access form then added text boxes over the existing ones on the original paper version. Users can then enter data in these controls. A print command button has been added however I have been unable to force the print output to fit on a single A4 page. Using DoCmd.Printout in a code module results in 4 pages with the Access form in parts printed on all 4 pages. After some angst I found PrtDevMode and PrtMip properties which I think are both needed to set DataOnly in PrtMip (=False prints graphics) and Orientation (=1 for portrait) and PaperSize (=9 for A4) in PrtDevMode. When the code below is run an error message results: Invalid use of null, caused by frm.PrtMip in

    PrtMipString.strRGB = frm.PrtMip

    Overall code I used is (sourced from Help on these variables and obviously misused):

    Option Compare Database
    Option Explicit

    Private Type str_PRTMIP
    strRGB As String * 28
    End Type

    Private Type type_PRTMIP
    xLeftMargin As Long
    yTopMargin As Long
    xRightMargin As Long
    yBotMargin As Long
    fDataOnly As Long
    xWidth As Long
    yHeight As Long
    fDefaultSize As Long
    cxColumns As Long
    yColumnSpacing As Long
    xRowSpacing As Long
    rItemLayout As Long
    fFastPrint As Long
    fDatasheet As Long
    End Type

    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 PrintSingleForm(strFormName As String)

    On Error GoTo Err_PrintSingleForm

    Dim PrtMipString As str_PRTMIP
    Dim PM As type_PRTMIP
    Dim frm As Form

    DoCmd.OpenForm strFormName, acDesign
    Set frm = Forms(strFormName)

    Set frm = Forms(strFormName)
    PrtMipString.strRGB = frm.PrtMip
    LSet PM = PrtMipString

    PM.fDataOnly = 0 ' Set to print graphics, labels and data
    PM.fDefaultSize = 0 ' set to size of detail section in design view

    LSet PrtMipString = PM ' Update property.
    frm.PrtMip = PrtMipString.strRGB

    Dim DevString As str_DEVMODE
    Dim DM As type_DEVMODE
    Dim strDevModeExtra As String

    If Not IsNull(frm.PrtDevMode) Then
    strDevModeExtra = frm.PrtDevMode
    DevString.RGB = strDevModeExtra
    LSet DM = DevString
    DM.lngFields = DM.lngFields Or DM.intOrientation ' Initialize fields.

    DM.intOrientation = 1 ' Set orientation = portrait
    DM.intPaperSize = 9 ' Set paper size to A4
    LSet DevString = DM ' Update property.
    Mid(strDevModeExtra, 1, 94) = DevString.RGB
    frm.PrtDevMode = strDevModeExtra
    End If


    GoTo Printed_OK

    Exit Sub

    MsgBox Err.Description
    Resume Exit_PrintSingleForm


    ' Close the print form
    DoCmd.Close acForm, strFormName
    DoCmd.Hourglass False

    End Sub

    Anyone have any ideas?



  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Print form with graphics (97 SR-2)

    Just because you have created a form that looks like a paper report doesn't mean it will print like one. Do yourself a favor and create an Access report with the same layout so that it looks like your graphic and print that instead. You absolutely *can* control that printout using PrtDevMode. We do it all the time, but we design special reports for our international clients to insure that everything will fit on A4 paper.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts