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

Automated printing to pdf creater help 1

Status
Not open for further replies.

Krullms

MIS
Aug 5, 2005
21
0
0
US
I have a database that when on my local pc when you click a button it will open a report and print it to a pdf creator and close the report. When I moved the database to a network drive it prints. Any ideas how I can keep this automated instead of just opening the report and having the user do a print then select the pdf creater?

Thanks
Mike
 
You need code to make a note of your default printer, set the printer to your PDF queue, print the report and then reset your print queue back to the default, e.g.
Code:
Dim prt As Printer
Set prt = Application.Printer 'Note default printer
Set Application.Printer = ... 'Your PDF print queue
' Code here to print the report - will vary depending on 
' where you're running this code from, e.g. with the 
' report already open or not
Set Application.Printer = prt 'Set default printer back
Hope this helps get you on the right lines.

[pc2]
 
Thank you for the response. That is pretty close to what I already have. Maybe i'm setting the printer to the pdf printer wrong?

'sets selected pdf printer
Dim PDFPrinter As String
PDFPrinter = Me.lstPrinters.Value

'change printer
Dim prt As Printer
Set prt = Application.Printer 'Note default printer
Set Application.Printer = Application.Printers(PDFPrinter) 'Your PDF print queue"

'print survey
DoCmd.OpenReport stDocName, acViewNormal

Set Application.Printer = prt 'Set default printer back

That is what I have which works when the database is on the local machine, but not a network shared drive

any ideas?

Thanks
Mike
 
I tried copying my code from an older version and that didn't work, BUT I ended up replacing my form and reports from a backup, and now it works...

Thanks for the help
-mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top