Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change printer settings programatically (Access 2000 - all updates)

    FrontEnd/BackEnd database construction.

    One of the features is being able to select names from a list box on a form and then print names, and accompanying addresses, on #10 commercial envelopes. Whenever I update the user's FrontEnd, the printer settings change from #10 envelopes to letter set-up.

    This, I believe, is due to the fact that the default printer is different on the user's computer than on mine.

    Is there a work-around code to fix this so that the Page settings don't have to be fixed each time an update of the FrontEnd is made?

    Thanks.

    Tom

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: change printer settings programatically (Access 2000 - all updates)

    Have you turned off Track Name AutoCorrect Info in the General tab of Tools | Options... in the frontend? This setting is stored in the database, and if it is on, it is known to cause reports to lose their page settings.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change printer settings programatically (Access 2000 - all updates)

    Hans
    Yes, I haven't used Name AutoCorrect for a long, long time.

    Tom

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: change printer settings programatically (Access 2000 - all updates)

    I'm afraid I don't know what causes it then. And changing page setup in code is a disaster in Access 2000 - look up PrtDevMode and PrtMip in the Access VBA help.

  5. #5
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change printer settings programatically (Access 2000 - all updates)

    Hans
    Thanks. Just looked up PrtDevMode and PrtMip. You are right...changing page setup by code in Access 2000 is a diaster.

    Tom

  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change printer settings programatically (Access 2000 - all updates)

    Tom

    This may be helpful, I have used it where users who have Laser default printer can print a report (designed for Matrix) to a Matrix printer

    When the Matrix printer report is selected the code saves the users default printer (Laser), then asks the user to select the default printer for this report (Matrix), when report is finished the users default printer is automatically restored to Laser in this case.

    This dosen't work in report Preview mode.

    HTH, John

    Chapter 10: Controlling Your Printer
    Paul Litwin
    Ken Getz
    With Mike Gilbert and Greg Reddick

    http://msdn.microsoft.com/archive/default....osoftAccess.asp

  7. #7
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change printer settings programatically (Acces

    I found some code that works. It uses the PrtDevMode. It's lengthy code but it does the job, so I thought I would post it in case it might help someone else.

    The function SetEnvelope has to be called when the form that drives the report is opened.

    Also note the line DM.intPaperSize = 20. In a book called "Access Cookbook" by Getz, Litwin etc. I found the setting value 20 for #10 envelopes. The book is really for Access 2002 but fixing the value at 20 works.

    Type str_DEVMODE
    RGB As String * 94
    End Type

    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 Function SetEnvelope(strName As String)
    Dim rpt As Report
    Dim strDevModeExtra As String
    Dim DevString As str_DEVMODE
    Dim DM As type_DEVMODE

    DoCmd.OpenReport strName, acDesign 'Opens report in Design view.

    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 = 20 '#10 Envelope size
    DM.intOrientation = 2 'Landscape
    LSet DevString = DM 'Update property.
    Mid(strDevModeExtra, 1, 94) = DevString.RGB
    rpt.PrtDevMode = strDevModeExtra
    DoCmd.Save acReport, strName
    DoCmd.Close acReport, strName
    End If

    End Function

    Tom

Posting Permissions

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