Check for installed printer???

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have a report in my Access database that must be printed to a specific
printer. Is there a simple Boolean function that I can pass the printer name
to so I can verify whether it has been installed on the computer?
 
I just put the following together, it should do the trick

Function Check4Printer(sPrinterName As String) As Boolean
On Error GoTo Error_Handler
Dim prtAvailPrinters As Printer

Check4Printer = False
For Each prtAvailPrinters In Application.Printers
With prtAvailPrinters
If sPrinterName = .DeviceName Then Check4Printer = True
End With
Next prtAvailPrinters

Error_Handler_Exit:
On Error Resume Next
Exit Function

Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: Check4Printer" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Back
Top