Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Printer Object (Access2003)

    I'm playing with the Printer object in Access2003. While many of the Printer properties (such as margins) can be set in a report's Open event at runtime, it appears that the only way to actually change which printer is being used requires that a report be opened first in design mode. This wouldn't be a problem, except if you wanted to do this in a .mde database! Is there a way to change the printer for a report in such a situation?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Printer Object (Access2003)

    I have done this sort of thing by formatting the report for the default printer, then changing the default printer in code.

    Dim prtDefault As Printer
    Set prtDefault = Application.Printer
    'remember the default so you can put it back later
    Set Application.Printer = Application.Printers("PDF995")
    ' set the default printer to pdf995
    ' now open the report and print it etc
    ' and eventually
    Set Application.Printer = prtDefault
    ' put the default printer back
    Regards
    John



  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Printer Object (Access2003)

    Thanks, but the problem is I've got a situation in which I am sending reports to 2 printers (a label printer and regular printer) from the same form, so I'm not sure what the problems will be in switching the default printer back and forth. The big problem with this technique, as I see it, is resetting the printer back to the original default. Can you do it immediately after issuing the "DoCmd.OpenReport" in code?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Printer Object (Access2003)

    I just tried this and it worked OK.


    DoCmd.OpenReport strReportname, acNormal, , strCriteria
    Set Application.Printer = prtDefault
    DoCmd.OpenReport strReportname, acNormal, , strCriteria

    I had set the default printer to a pdf creator, so the first line above made a pdf, then the third line sent the same report to the default printer.
    Regards
    John



  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Printer Object (Access2003)

    Thanks. I was trying to figure out how to test it without a 2nd real printer.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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