• Printer Object (Access2003)

    Author
    Topic
    #438338

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #1044859

      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

      • #1044878

        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?

        • #1044951

          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.

    • #1044953

      Thanks. I was trying to figure out how to test it without a 2nd real printer.

    Viewing 1 reply thread
    Reply To: Printer Object (Access2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: