Setting Printer by Code??

D

Don V

Here's the code I have.
What am I doing wrong?
I'm attempting to change the printer from a command button
It works but prints out on my default printer and does not change the
printer to Winfax.


Private Sub cmdFax_Click()

On Error GoTo Err_cmdFax_Click

Set Application.Printer = Application.Printers("WinFax")
DoCmd.PrintOut acSelection
Exit_cmdFax_Click:
Exit Sub

Err_cmdFax_Click:
MsgBox Err.Description
Resume Exit_cmdFax_Click
End Sub


Don
 
A

Albert D. Kallal

Are you use you have the right printer name?

Try removing the error code, and see what happens.

You can also try running the following code in a module, and see what the

actual printer names are:

Dim i As Integer

For i = 0 To Application.Printers.Count - 1
Debug.Print Application.Printers(i).DeviceName
Next i

The above results are sent to the debug window.
 
D

Don V

Are you use you have the right printer name?
<Snip>
Thanks for the reply.
I have the right printer name. I'm wondering if the problem lies in the
fact I'm trying to do this from a command button on a form.

Don
 
A

Albert D. Kallal

My guess is that you perhaps has report with the printer set.

I would also consider setting the printer before you open the report.

If you are trying to print a form, then get rid of that idea, and use a
report.
 

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