View Full Version : Roporttopdf and email


Lanser
04-05-2010, 02:58 AM
Hi All,
I'm using A2003 and using Lebans excellent code I have managed to get as far as creating a pdf from a report and emailing it, but I am trying to give each one a unique name based on a field in the report
This is my current code
Dim strFilter As String
strDocName = "Issue"
strFilter = "Id = Forms!Issues!ID"

DoCmd.OpenReport strDocName, acPreview, , strFilter


Dim blRet As Boolean
blRet = ConvertReportToPDF("Issue", , "T:\Issues\Issue" & ".pdf", False, False)
SendMessage True, "T:\Issues\Issue.pdf"

DoCmd.Close acReport, "Issue"


I have tried variations like this

blRet = ConvertReportToPDF("Issue", , "T:\Issues\Issue" & strFilter & ".pdf", False, False)

SendMessage True, "T:\Issues\Issue[strFilter].pdf"

DoCmd.Close acReport, "Issue"

but that just gives me a filename of IssueId = Forms!Issues!ID how do I make it give me the actual Id to save it then be able to add to the sendmessage code?

stopher
04-05-2010, 03:03 AM
Probably more like:

blRet = ConvertReportToPDF("Issue", , "T:\Issues\Issue" & Forms!Issues!ID & ".pdf", False, False)

SendMessage True, "T:\Issues\Issue" & Forms!Issues!ID & ".pdf"

DoCmd.Close acReport, "Issue"


hth
Chris

Lanser
04-07-2010, 08:41 AM
Excellent works perfectly, thanks

Lanser
04-13-2010, 05:06 AM
Follow up question I decided to try and make each save unique by doing this to add the time to the filename using a field on the form called Time but it just saves as Issue2Forms!Issues!Time.pdf

blRet = ConvertReportToPDF("Issue", , "T:\Issues\Issue" & Forms!Issues!ID & Forms!Issues!Time & ".pdf", False, False)