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
    The only technique I know for changing the printer and/or paper used for a report via code is to first open the report in Design Mode (hidden), modify the Printer settings, close (and save) the report, then actually print it.

    While this works good enough and is transparent to the user, it is limiting. I can't use it with .mde databases or in situations where user only has a runtime version of Access.

    Is there another (better) way to assign a specific printer to a report?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can assign a printer to a report after it has been opened in preview mode:

    Reports("rptMyReport").Printer = Application.Printers("MyPrinter")

    You can't change the printer in the On Open event of the [s]printer[/s] report though.

  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
    [quote name='HansV' post='799796' date='25-Oct-2009 11:02']You can assign a printer to a report after it has been opened in preview mode:

    Reports("rptMyReport").Printer = Application.Printers("MyPrinter")

    You can't change the printer in the On Open event of the printer though.[/quote]
    That's the same line of code I'm using now to change the printer after opening it in design mode. I was thinking I had to save the report after setting the printer and then print it, but I really don't have to do that; I can just print it while it is open in preview (I can do it hidden so user isn't confused). This does means I'd have to do this every time I went to print that report (rather than making it a permanent change in the report). I was worried that opening the report in preview mode and then resetting the printer (causing the report to reformat) might be a performance issue, but the reality is that most of the time I use a special printer it is for things like a Receipt printer, where I'm only printing 1 record anyway.

    Thanks, I'll give it a try.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    [quote name='MarkLiquorman' post='799804' date='25-Oct-2009 15:48']That's the same line of code I'm using now to change the printer after opening it in design mode. I was thinking I had to save the report after setting the printer and then print it, but I really don't have to do that; I can just print it while it is open in preview (I can do it hidden so user isn't confused). This does means I'd have to do this every time I went to print that report (rather than making it a permanent change in the report). I was worried that opening the report in preview mode and then resetting the printer (causing the report to reformat) might be a performance issue, but the reality is that most of the time I use a special printer it is for things like a Receipt printer, where I'm only printing 1 record anyway.

    Thanks, I'll give it a try.[/quote]

    There's a good section in the Litwin, Getz books Access 2002 Developer's Handbook, also in the 97 and 2000 version,
    with a load of free API code to handle Printers.
    If you can find someone with the book, it is all on the CD.
    Andrew

  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
    [quote name='HansV' post='799796' date='25-Oct-2009 11:02']You can assign a printer to a report after it has been opened in preview mode:

    Reports("rptMyReport").Printer = Application.Printers("MyPrinter")

    You can't change the printer in the On Open event of the [s]printer[/s] report though.[/quote]
    I don't think this will work out the way I want it. If you open the report in preview mode, you can't make it hidden, so the whole operation (that I wanted to keep out of the user's view) happens right there on the screen.

    I may go to changing the Application.Printer property. There is an exposure to problems if it is not properly reset before the next report prints, but at least I know I can use it in .mde and runtime situations.
    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
  •