Check for installed printer???

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?
 
D

Daniel Pineault

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top