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!