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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can one print reports to different printers?

Status
Not open for further replies.

ocb

IS-IT--Management
Nov 5, 2003
78
NO
Is there any chance that an Access report can be automatically printed using scheduled tasks on a PC that have no printers installed?

I'm trying to make a bat-file that says:

"c:\program Files\Microsoft Office\Office10\msaccess.exe" "c:\myfolder\mydb.mdb" /xPrintReport

where /xPrintReport is a macro that prints a report and then quit access.

And put the bat-file into Scheduled Tasks on a PC.

But what if I want to print the report to a printer that is not my Default printer? Or if the PC has no printer at all? Is there any tricks on re-directing the print outs to another printer, ex \\printserver\printname?

Any tricks anyone?
 
You can use VBA to change the default printer, e.g.
Code:
' Declare printer variable
Dim prt As Printer
' Set variable to current default printer
Set prt = Application.Printer
' Change default printer
Application.Printer = Application.Printers("\\YourPrintQueueNameHere")
' Do your code here (e.g. print something)
' Set printer back to original default
Application.Printer = prt
Set up a macro to call this VBA, then use a scheduler to run the macro.

As an aside, you may find the Handy Access Launcher ( a more useful tool for scheduling Access macro runs (and other admin tasks too).
 
The command

application.printer=application.printers("\\printserver\printer") gives the error message:

Invalid procedure call or argument.

And if I press "Debug", the line mentioned turnes yellow. I have checked the spelling on the printer, and it is correct. I even tried to look at all printers by the sub:

Sub chkprinters()
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

End Sub


And I can see printers withe the correct names, but can't change the default printer by entering the code You specified.

Wonder what is incorrect with the command.
 
By the way - how do you insert the code in its own frame?

 
Which version of Access are you using? THe Application object wasn't introduced until Access 2002, so maybe this is causing your error.
 
2002 SP3

strange
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top