I have this code that is under an "Email Invoice" command button. It works fine, as in, when clicked, it opens a form to the current invoice, converts it to a PDF and attaches to an email.
The first problem is that I can't get the Close Form code to actually close the form.
The Second problem is that the MyFileName code is not naming the filename the way I would like. It is just naming it Tecterra Invoice.PDF, rather than 2013-GL0001-Tecterra Invoice (Which is how the subject looks)
The first problem is that I can't get the Close Form code to actually close the form.
The Second problem is that the MyFileName code is not naming the filename the way I would like. It is just naming it Tecterra Invoice.PDF, rather than 2013-GL0001-Tecterra Invoice (Which is how the subject looks)
Code:
Subject = Me.txtInvoiceNumber & "-" & "Tecterra Invoice" & ".pdf"
MyFileName = " & Me.txtInvoiceNumber & " & "-" & "Tecterra Invoice" & ".pdf"
' Open Invoice form in preview mode
DoCmd.OpenForm "frmrptCurrentRecordInvoice", acNormal, , "[InvoiceID]= forms!frmInvoicing![InvoiceID]"
' Send a PDF of the form to an email
DoCmd.SendObject acForm, "frmrptCurrentRecordInvoice", "PDFFormat(*.pdf)", "", "", "", Subject, "Hello, attached you will find a PDF of your current TECTERRA invoice.", True, ""
' Close the form
DoCmd.Close acForm, "frmrptCurrentRecordInvoice"