Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2024
    Posts
    1

    Silent print a specific report from a form's button click event to a receipt printer

    I have a form that contains a button to generate and print a report. I currently have it to display the report and to open the print dialog. I would like to not see the report on screen, nor the print dialog. I would like my report to just silently print to a receipt printer that I know will contain "Epson" in the name. Originally the click event was a macro, but thought that I would have more granular control by converting to VBA. My current function is as follows:
    Code:
    DoCmd.OpenReport "rept_receipt", acViewReport, "", " [qry_payments_extended]![PaymentID]=" & PaymentID, acNormal
    DoCmd.RunCommand acCmdPrint
    First I attempted a combobox on the form to default and display a printer with "Epson" in the name and is visible on the form just for verification that the correct printer was found. The Row Source Type is set to Value List and the form load event contains:


    Code:
    Dim prn As Object
      
      For Each prn In Application.Printers
        Me.cbo_Printers.AddItem prn.DeviceName
      Next prn
    This fills in the combo box with the list of printers....

    Then I started to set the Default Value for the combobox is set to the expression (unfinished obviously)
    Code:
    =[cbo_Printers].ListRows(---return of index of device with the name containing "*Epson*"---)
    but I found a forum statement that VBA does not have a printers collection, so figured that was a dead end.

    I saw some other documentation that someone accomplished this by using WMI in part:
    Code:
     'Get the WMI object
        Set wmiService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & computer & "\root\cimv2")
        
        'Retrieve information about the installed printers (by running a query).
        Set installedPrinters = wmiService.ExecQuery("Select * from Win32_Printer")
    Is this even possible or am I just spinning my wheels and am going to have to just use the print dialog?

    Thanks in advance!

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Perhaps you can open the report as non visible and assign a printer so:

    Code:
           Screen.ActiveReport.Printer = application.Printers(strPrinterName)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to get printer printer options
    By darkdemon in forum Forms
    Replies: 6
    Last Post: 11-09-2020, 05:58 PM
  2. Virtual thermal receipt printer
    By bilalo in forum Reports
    Replies: 1
    Last Post: 02-24-2020, 01:43 PM
  3. Replies: 14
    Last Post: 02-07-2020, 12:42 PM
  4. Nonprofit Silent Auction Database Help
    By blueboy18 in forum Access
    Replies: 2
    Last Post: 09-04-2018, 04:25 PM
  5. Replies: 3
    Last Post: 02-25-2014, 11:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums