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!

VBA sample code to use a control button to move a print doc to PDF

Status
Not open for further replies.

lr999

Technical User
May 16, 2011
30
US
I need to use the same print button for PDF.
the following is the print button code:

Private Sub Print_Click()
On Error GoTo Err_Print_button_Click
Dim stDocName as String
Dim stLinkCriteria As String

stDocName = "Script"

stLinkCriteria = "[ScriptID]=" &Me![ScriptID1]
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria
Exit_Print_button_Click
End Sub

I need a sample code to add a control button to transfer the same doc to PDF or can I use the same print button for dual option(either to print or to send to PDF)?
Thanks
 
Try something like this:

Dim stDocName As String

stDocName = "your report"
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "your path\your report name.PDF"
 

can I use the same print button for dual option(either to print or to send to PDF)?

Yes, you can.
But what do you want to happen? Have it print? Or send it to PDF?

If you want both - add Dom606's code to your code.

If you want either/or, how are you going to comunicate it with the user?


Have fun.

---- Andy
 
Hi
I tried the code, but I'm working in Access 2000, there is no PDF support, so acFormatPDF didn't work. Any other code samples?
 
Here you go, google A2000ReportToPDF:

A2000ReportToPDF is an Access 2000 database containing a function to convert Reports and Snapshot files to PDF documents. No PDF Printer driver is required. This archive contains new versions of the StrStorage and DynaPDF libraries. Please make sure you delete your old versions, especially if you copied them into your Windows\System32 folder.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top