Weird printer selection

Bioman

Registered User.
Local time
Today, 13:04
Joined
Feb 28, 2002
Messages
29
Hi!

The code below set the printer correctly (\\wxp-021\hp1210Shipping), but the application print the report on the other printer (\\wxp-018\NetPrintQueue2Fax). Just before the OpenReport command, I put a MsgBox, and the Application.Printer is really \\wxp-021\hp1210Shipping, but it print on the \\wxp-018\NetPrintQueue2Fax :confused:

For i = 0 To Application.Printers.Count - 1
If sDest = "Shipping" Then
If Application.Printers.Item(i).DeviceName = "\\wxp-021\hp1210Shipping" Then
Set Application.Printer = Application.Printers(i)
Exit For
End If
Else
If Application.Printers.Item(i).DeviceName = "\\wxp-018\NetPrintQueue2Fax" Then
Set Application.Printer = Application.Printers(i)
Exit For
End If
End If
Next i

If bLang Then
DoCmd.OpenReport "Fax_Anglais", acViewNormal
Else
MsgBox Application.Printer.DeviceName 'Result: \\wxp-021\hp1210Shipping
DoCmd.OpenReport "Fax_Francais", acViewNormal 'Result: Print on the \\wxp-018\NetPrintQueue2Fax
End If
 
Bioman,

Using this code, if the destination is shipping, it will print on
whichever of the two printers it finds first. I guess that the
Fax machine is defined first.

If sDest is not "Shipping", it won't print on any printer.

Code:
For i = 0 To Application.Printers.Count - 1
   If sDest = "Shipping" Then
      If Application.Printers.Item(i).DeviceName = "\\wxp-021\hp1210Shipping" Then
         Set Application.Printer = Application.Printers(i)
         Exit For
      End If
   Else
      If Application.Printers.Item(i).DeviceName = "\\wxp-018\NetPrintQueue2Fax" Then
         Set Application.Printer = Application.Printers(i)
         Exit For
      End If
   End If
Next i

Wayne
 

Users who are viewing this thread

Back
Top Bottom