Results 1 to 9 of 9

Thread: Access Changing the printer

  1. #1
    Hyperactive Member
    Join Date
    Aug 01
    Location
    Austin
    Posts
    397

    Access Changing the printer

    Have you ever changed the default printer from code?

    I need to change the default printer and then change it back to the original printer.

  2. #2
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 00
    Location
    In my sphere of influence
    Posts
    621
    I use this to set the printer on a till that prints receipts.

    VB Code:
    1. Dim pPrinter As Printer
    2.  
    3.          For Each pPrinter In Printers
    4.             If pPrinter.DeviceName = gstrReportPrinter Then
    5.                 ' Set printer as system default.
    6.                 Set Printer = pPrinter
    7.                 ' Stop looking for a printer.
    8.                 Exit For
    9.             End If
    10.         Next

    The gstrReportPrinter is a string that holds the name of the printer I want to use.

    I loop through the availablre printers and when I find the one I want set the printer object to use that one

    Hope this Helps.
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  3. #3
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283
    The Printer Object is supported in VB, but not (to my knowledge) in VBA, so Gary's code is not going to work for you.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  4. #4
    Hyperactive Member
    Join Date
    Aug 01
    Location
    Austin
    Posts
    397
    What is wrong with this code? I want it to print to Acrobat and not the default printer.

    Code:
    Option Explicit
    Private acc As Access.Application
    
    Private Sub Command1_Click()
    Dim pPrinter As Printer
    Dim view As Long
    Dim acdstl As String
    
        acdstl = "Acrobat Distiller"
        Set acc = New Access.Application
        
             For Each pPrinter In Printers
                If pPrinter.DeviceName = acdstl Then
                    ' Set printer as system default.
                    Set Printer = pPrinter
                    ' Stop looking for a printer.
                    Exit For
                End If
        Next
        
        acc.OpenCurrentDatabase ("C:\Documents and Settings\ihayse\Desktop\Monthly\Member Reports.mdb")
        acc.DoCmd.OpenReport "AB_Add-Drop by PCP Labels", acViewNormal 'acViewNormal means the report is just printed.
        acc.CloseCurrentDatabase
        Set acc = Nothing
          
        
    End Sub

  5. #5
    Hyperactive Member
    Join Date
    Aug 01
    Location
    Austin
    Posts
    397

    Talking

    I got it.........

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283
    If you got it, post it....it could, and probably will, help someone else.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  7. #7
    Hyperactive Member
    Join Date
    Aug 01
    Location
    Austin
    Posts
    397
    The code above will not print Access Reports. For some reason when it comes to print Access Reports they are going through the default printer. But if I say form1.printform it will send the form to the Distiller but not the Access Report.......

  8. #8
    Hyperactive Member
    Join Date
    Aug 01
    Location
    Austin
    Posts
    397
    FYI


    You can change the default printer for each and ever Access Report in the "Page Setup" of the report.....

  9. #9
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283
    Thanks!
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

Posting Permissions

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