VBA Check for printer

S

Sandy

Hi
I have the following code on a command button and it works fine other than
if someone forgets to turn the printer on.
Is there any code that can be incorporated to check if there is a printer
connected and in particular is switched on, and if it isn't then throw up a
message box (say "No Printer Available"), and then exit the routine?

Command Button code as follows:-

Private Sub cmdPrintSaveClose_Click()
On Error GoTo Err_cmdPrintSaveClose_Click

DoCmd.OpenReport "Customer Copy", acNormal
DoCmd.OpenReport "Workshop Copy", acNormal
DoCmd.OpenForm "Navigation", acNormal

Exit_cmdPrintSaveClose_Click:
Exit Sub

Err_cmdPrintSaveClose_Click:
MsgBox Err.Description
Resume Exit_cmdPrintSaveClose_Click
End Sub

Thanks
Sandy
 
A

Allen Browne

In Access 2002 and later, you can test if the workstation has any printers
installed like this:
If Printers.Count = 0 Then MsgBox "No printer"

Beyond that, there is no simple solution to test if the printer is
operational. There are many, many factors here, such as:
- The report may be assigned to a particular printer (not the Windows
default)

- The Printer object in Access may be set to something other than the
Windows default.

- The printer could be a network printer.

- The printer cable may not be plugged in.

- The printer may be on, but have an error (paper jam, no paper, toner, ...)

- The printer may not be a physical device (e.g. it might be creating a file
such as a PDF.)

Even if you could check all those things, there is still no guarantee that
the printer will still be operational after it finishes the other jobs in
its queue and gets to yours.
 
S

Sandy

Thanks for your comprehensive reply Allen.
Didn't appreciate the difficulties and intricacies - I think a general
message to ask for a printer check might be the answer.
Thanks again
Sandy
 

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

Similar Threads

Select printer 1
Printing report to PDF file 5
Report printing 1
Report printing 15
Command Button Not Executing 24
Report printing problem 2
2003 - 2007 VBA issue 6
Error running code from Switchboard 4

Top