Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8

    Unanswered: Change the Default printer with vbcode

    How can I change the Use specific Printer on The Fly
    vb codeing

    my current Work round is having 3 reports came just pointing differnace printer

    (have to remneber to change all 3 if there is a change yestday i forgot 2 of then the job are run @ nite time.)

    I would like to go back to 1 report and print 3 time to the differnace printers
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  2. #2
    Join Date
    Feb 2002
    Posts
    108
    I have the same problem with about four different reports and five different forms where I have multiples where the only difference is the specific printer assigned.

    Can anyone help ?, You'll be helping at least two people.

  3. #3
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    Have a look Here

    It may be of assistance to you both.
    Regards,



    John A

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i have a note under this topic in my code-bank:
    open report preview
    docmd.runcommand accmdprint
    issues:
    report must be current active window
    must error trap for the cancel button

    i cannot say if it works or not since i am forced to take a different route.
    i hide the access mother-window to make my applications look more like a 'real application'. one consequence of this decision is that i cannot use report preview - preview collapses the mother-window hide.
    so my reports are 100% always snapshot format saved to something like c:\temp\myreport.snp and then opened for preview by shelling snapview.exe
    the snapshot viewer menu provides printer selection, mailto, etc.

    if you want a more sophisticated approach, google prtdevmode
    (sorry: the earlier mvps link was a link-to-links which were collectively not particularly illuminating)


    izy

    EDITS in this colour
    Last edited by izyrider; 08-19-06 at 17:11.
    currently using SS 2008R2

  5. #5
    Join Date
    Aug 2006
    Location
    Thailand
    Posts
    12
    In VB6:
    Public Function SelectPrinter(ByVal PrinterName As String) As Boolean
    Dim prThis As Printer
    If Printers.Count > 0 Then
    For Each prThis In Printers
    If prThis.DeviceName = PrinterName Then
    Set Printer = prThis
    SelectPrinter = True
    Exit For
    End If
    Next prThis
    End If
    End Function

    Private Sub Command1_Click()
    SelectPrinter ("Printer name")
    Me.PrintForm '=Just example
    End Sub
    Last edited by polngpole; 08-24-06 at 13:18.

  6. #6
    Join Date
    Feb 2002
    Posts
    108
    polngpole,

    Thanks, this works great and is so easy.
    Hope I can return the favor one day !!

  7. #7
    Join Date
    Feb 2002
    Posts
    108
    Anyone know if there is a way to get the current printer name before you change it ? so you can set it back.

    Using polngpole's solution works great but one side effect is, system continues to use the printer you change to on subsequent reports or prints.
    Still a GREAT solution though.

Posting Permissions

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