Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to a Network Printer 1

Status
Not open for further replies.

Pugs320

Technical User
Jan 29, 2002
19
US
How can I print a report to a network printer that is not my default printer? Right now I print to my default printer and I have to run the report across the building to the right department. I tried going through the help topics but I didn't see anything about this. Does anyone know code to change the default printer and then change it back after the report is printed? Is this the right way to do it?

Andy %-)
 
Application.ActivePrinter = "location of printer"

This sets your active pritner to what ever you want.

dyarwood
 
If you want to find the location of the Active printer use

MsgBox(Application.Activeprinter)

dyarwood
 
Thanks for your quick response Dyarwood. I tried this but I get a compile error on ActivePrinter. The error is "Method or Data Member not found". I have Access 97.

Andy
 
This may help

Dim prtLoop As Printer

For Each prtLoop In Application.Printers
With prtLoop
MsgBox "Device name: " & .DeviceName & vbCr _
& "Driver name: " & .DriverName & vbCr _
& "Port: " & .Port
End With
Next prtLoop
You can refer to an individual Printer object in the Printers collection either by referring to the printer by name, or by referring to its index within the collection.

The Printers collection is indexed beginning with zero. If you refer to a printer by its index, the first printer is Printers(0), the second printer is Printers(1), and so on.

The code I gave I think might just be for Excel

dyarwood
 
If you are using the PrintForm command then the default printer is always used.
 
If you have to fix one particular report to a printer other than default,
you can just select the report in access window. Goto File->Page Setup->PAge(Tab) and select the option Specific Printer

If this is a generic case you can setdefaultprinter using API calls.
This is one of the results I got from searching Tek-tips for Set Default Printer. You can check on it

Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal PrinterName As String) As Boolean


You pass in the name of the printer you want to become the default printer for the system when you call the function

SetDefaultPrinter Printer.DeviceName

 
There is no easy way to do what you want in A97, but there is a way.
The easy way is to buy the "On-The-Fly" code from
The cheap way is to use the code from which uses the api calls and UDT's that MinusM talks about.
There is a demo db of the code from that chapter at
(it's chapter 10 by the way!)

The book the code comes from is a worthy addition to anyone's library.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top