Selection of a Printer

I

Irshad Alam

On 19-12-2004 in an aswer to my same topic Mr. Ken Snell - MVP wrote the
following code for selecting a printer :
Set Application.Printer = Application.Printers("DeviceName")

Based on that I made a command Button and wrote the following code to select
one of my printer and print the report (my PC is attached with 2 Printer, One
on parralled port - (Name = Epson LQ-2180) and other one on USB port (Name=hp
Deskjet 920c)). The code I wrote was.

Private Sub Label0_Click()
DoCmd.OpenReport "EmplRepo5", acNormal, "", ""
Set Application.Printer = Application.Printers("Epson LQ-2180")
End Sub

Its shows error on the printer selection line code.

Please advise what code lines I should add to obtain this.
 
A

Allen Browne

The code looks right for Access 2002 or 2003. (From memory, the Printer
object was introduced in A2002.)

To debug it, open the Immediate window (Ctrl+G), and enter:
? Application.Printers(1).DeviceName
Change the numbers until it gives you the exact name it expects for the
printer.

BTW, you need to assign the printer before you open the report in acNormal,
so switch your 2 lines of code around.
 
I

Irshad Alam

Sir,
As you advised, in the module window I used (Ctrl+G) and in the opened
Immediate Window, I typed :

?Application.Printers(1).DeviceName

It shows error "Compile error !! Method or data member not found "

I have MS Office 2000 installed on my computer.

Please advise me, what code should I write to obtain this function for
selection of my required printer.

Regards
 

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