none
DoCmd.printOut won't print to Application.Printer RRS feed

  • Question

  • I have an Access 365 app that pops up a custom print dialog box with every report. The dialog box fills a dropdown with all the available printers, from which the user can select. This has worked for years (I originally developed it in Access 2010).

    All of a sudden, regardless of which printer the user selects, the report goes to the default printer every time. For example, my default is "Microsoft print to pdf", and the when I hit print I'm presented with a Windows explorer dialog box asking me where it should save the pdf. 

    dim ptr as printer
    Set ptr = Application.Printers(ddPrinters.Value) 'as selected by user
    Set Application.Printer = ptr
    DoCmd.SelectObject acReport, rptName
    DoCmd.PrintOut acPrintAll, , , acHigh
    
    
    Has something changed in Windows or in Access that the PrintOut command will now only print to the default printer?


    Darrell H Burns

    Wednesday, February 26, 2020 1:08 AM

All replies

  • In Windows.

    MSFT figured people were incapable of setting the default printer, so they set it for them. And may change it as it sees fit.

    Explicitly set the default printer in Devices and Printers. You may get a warning as below, but after that you're in control.

    [Window Title]
    Printers

    [Main Instruction]
    Setting this printer as default means Windows will stop managing your default printer.

    [OK] [Cancel]


    -Tom. Microsoft Access MVP

    Wednesday, February 26, 2020 4:15 AM
  • You might like to take a look at LabelPrinter.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    This little demo file includes a custom dialogue form, frmPrinterDlg, for selecting a printer.  It works fine with my Access 365 installation, though the file uses the OpenReport method of the DoCmd object, rather than the PrintOut method.  Do you get the same behaviour if you use the OpenReport method?

    Ken Sheridan, Stafford, England

    Wednesday, February 26, 2020 12:27 PM
  • <Explicitly set the default printer in Devices and Printers. You may get a warning as below, but after that you're in control.>

    I did set the default printer to a real printer Tom, but DoCmd.printOut still went to Microsoft Print to PDF...


    Darrell H Burns

    Wednesday, February 26, 2020 7:52 PM
  • No, unfortunately using DoCmd.OpenReport made no difference

    Darrell H Burns

    Wednesday, February 26, 2020 8:40 PM
  • Using Office 365, I cannot reproduce the behaviour which you are experiencing, using either the OpenReport or PrintOut method.  With the latter, I've also tried selecting the report in the navigation pane with True as the InDatabaseWindow argument of the SelectObject method, rather than opening the report in Print Preview first.  In every case the report prints correctly to the selected printer.

    It would be interesting to see whether you have the same problem with my LabelPrinter demo.  If you do, it would suggest the problem is not confined to your file, but more generalised in origin.

    Ken Sheridan, Stafford, England

    Thursday, February 27, 2020 12:00 AM
  • Instead of trying to set the printer with a combo box and the VBA code you have, try:

    DoCmd.SelectObject acReport, rptName

    Application.CommandBars.ExecuteMso ("PrintDialogAccess")

    This will call the native ACCESS Printer dialog after the report is selected. You can use the dialog to change printers as well as set other options before printing. Maybe this will work better for you.

    Thursday, February 27, 2020 12:13 AM
  • Hi Darrell,

    Have you check the Report Page Printer Setup?

    Open the Report in Design View - Go to Page Setup - Go to Page Tab - Go to Printer For "your report name"

    Check is it "Default Printer" or "Use Specific Printer"?

    It might be bound to "Use Specific Printer" - "Microsoft Print to PDF".

    HTH

    PS. If it is, you'll need to remove it and save the Report.
    Tuesday, March 3, 2020 7:25 AM