VB syntax for network printing

plucnik

Registered User.
Local time
Today, 12:27
Joined
Nov 11, 2003
Messages
34
I've seen several posts regarding this but none seemed to answer the question We have several network printers. I would like to hardcode the output of a specific report to a specific printer. Using the acPrint command sends the report to the shared server "default" printer. I would like to direct the report to the \\server\lanier5635 shared printer. Thanks for any advice!
 
The simplest way I have found to do this without a lot of coding is to make a copy of the report and give it a different name. Then when in design mode, select Page Setup, Page and select Specific Printer. You can then locate the printer you require, and then save the report. I then put cmdButtons on the form saying "Print To Here" and "Print To There" etc with each button actually printing a different report.

HTH

Dave
 
Another way around this is to do the following. When this code is added it brings up the "PrintTo" dialog box so you can select where you want the report to go.

Print dialogue box:

Set the code on the command button to docmd.openreport “ReportName”,acViewPreview

Add the following to the "On Activate" event of the report.

Private Sub Report_Activate()
On Error GoTo Err_Report_Activate

If Me.Report.HasData Then
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Me.Name

Else
MsgBox "There is no data for this report. Canceling report...", vbInformation, " Your App"
DoCmd.Close acReport, Me.Name

End If

Err_Report_Activate:
Resume Next
DoCmd.Close acReport, Me.Name

End sub
 
Last edited:
Thanks for the reply. I actually have the report running automatically each day from an "autoexec" macro so using command buttons to direct the report to a printer that way really isn't an option. I didn't think about the page setup. I guess I assumed that a report would always go to the default printer. I'll look into that. I'm more of an IT tech than a programmer so I ask a lot of dumb questions when it come to code. :confused:
 
If you are printing the report from a macro, go with the first suggestion and create a copy report and set the Page SetUp on the copy to the printer you want. The macro can then send this report, and you wont have to write any code at all! :D

Dave
 

Users who are viewing this thread

Back
Top Bottom