Hi all,
I email my invoices as a pdf attachment from Access (2013).
After a long search and tinkering, I found a method that the invoice no. is set up as the pdf file name.
I do that with
i.e. the report is opened and the document name is replaced with the invoice no., then the invoice is send with
and attached as a pdf.
Everything works well so far, but unfortunately the generation "swallows" when I want to send several invoices, i.e. the generation of the first invoice works perfectly. If I then want to create another subsequent invoice, the correct current invoice number is shown in the e-mail. (also as Attachment-name) but the attachment itself contains the previous invoice. If I cancel the process, the report printout of the previous invoice is displayed on the monitor. I then have to close it manually.
The close instructions didn't help either.
If I remove
then I don't have the problem but also no invoice number as file name.
Can you help me?
P.S. I transfer the invoice number to the report with aInvID
I email my invoices as a pdf attachment from Access (2013).
After a long search and tinkering, I found a method that the invoice no. is set up as the pdf file name.
I do that with
Code:
DoCmd.OpenReport strDocName, acViewPreview, , , acHidden
Reports(strDocName).Caption = sAttachmentName
i.e. the report is opened and the document name is replaced with the invoice no., then the invoice is send with
Code:
DoCmd.SendObject acSendReport, strDocName, acFormatPDF, "" & Me!EmailCus & "", _
and attached as a pdf.
Everything works well so far, but unfortunately the generation "swallows" when I want to send several invoices, i.e. the generation of the first invoice works perfectly. If I then want to create another subsequent invoice, the correct current invoice number is shown in the e-mail. (also as Attachment-name) but the attachment itself contains the previous invoice. If I cancel the process, the report printout of the previous invoice is displayed on the monitor. I then have to close it manually.
The close instructions didn't help either.
Code:
DoCmd.Close acReport, strDocName
DoCmd.Close acReport, "CurrentRecord"
If I remove
Code:
DoCmd.OpenReport strDocName, acViewPreview, , , acHidden
Reports(strDocName).Caption = sAttachmentName
then I don't have the problem but also no invoice number as file name.
Can you help me?
P.S. I transfer the invoice number to the report with aInvID