Hi All
I have been trying without luck to change the output path for the PDF file when the e-mail button on a form is clicked.
the code i use is below
Private Sub E_Mail_Invoice_Click()
'This Command Opens the report in hidden mode so that the calculations work on the Report when it's output as a PDF
DoCmd.OpenReport "Invoice", acViewPreview, "", "", acHidden
DoCmd.OutputTo acOutputReport, "Invoice", acFormatPDF, "C:\Users\Steve\SkyDrive\Access\Invoice.pdf"
Dim OlApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set OlApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set OlApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If
'Create e-mail item
Set objMail = OlApp.CreateItem(olMailItem)
'Set objOutlookAttach = .Attachments.Add("C:\Users\Steve\SkyDrive\Access\I nvoice.pdf")
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = Me.EMail.Value
.Subject = "Forest PC Repairs Invoice Attached"
.HTMLBody = "Dear" & " " & Me.Full_Name.Value & " " & Me.Email_Body_text.Value
.Attachments.Add ("C:\Users\Steve\SkyDrive\Access\Invoice.pdf")
.Display
End With
DoCmd.Close acReport, "Invoice", acSaveYes
Me.Order_Sent_Date = Date
End Sub
on a form called "Company Details" i have a text box that is bound to a field in the Company Details table called "FilePath" i would like this to be used for the acOutputReport
how can i reference the "FilePath" in the "Company Details" Table into the code above?
any help would be awesome.