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!

Rename Report for Print to PDF

Status
Not open for further replies.

LJtechnical

Technical User
Aug 7, 2002
90
0
0
GB
Hi All,

I am trying to make a report print to PDF automatically using a record no: for the file name. The following code does the job quite well, by utilising the Rename command twice.

stQuoteNum = Me![QuotationNo]
stDocName = "QuotePDFUK"
DoCmd.Rename stQuoteNum, acReport, stDocName 'Rename with record number
DoCmd.OpenReport stQuoteNum, acNormal
DoCmd.Rename stDocName, acReport, stQuoteNum 'Revert back to original filename

The only problem here is that to do this you have sole use of the Database to carry out this task. Also I'm not convinced this is the safest way of achieving what I want as if the process gets interrupted it is possible to lose the original filename.

Any suggestions gratefully received.
 
Insterad of renaming, use CopyObject to create a diferently named copy. THen run the report. Then delete the copy.
Code:
stQuoteNum = Me![QuotationNo]
stDocName = "QuotePDFUK"
DoCmd.CopyObject stQuoteNum, acReport, stDocName
DoCmd.OpenReport stQuoteNum, acNormal
DoCmd.DeleteObject acTable, stQuoteNum

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top