mike60smart
Registered User.
- Local time
- Today, 03:14
- Joined
- Aug 6, 2017
- Messages
- 1,993
Hi Everyone
Vlad gave me what I thought was a solution in the following Link, however I now find I am getting the following error.
Link
The Code I am using is as follows.
Any help appreciated.
Vlad gave me what I thought was a solution in the following Link, however I now find I am getting the following error.
Link
The Code I am using is as follows.
Any help appreciated.
Code:
Private Sub cmdPreview_Click()
10 On Error GoTo cmdPreview_Click_Error
20 If Me.CarrierPaid = -1 Then
30 If Me.Dirty Then Me.Dirty = False
40 MsgBox "A Copy of the PDF will be saved to the C Drive EMails Folder", vbInformation
Dim strSQL As String
Dim outApp As Object
Dim outMail As Object
Dim strReportname As String
Dim strMailItem As String
Dim strWhere As String
Dim strToWhom As String
Dim strMsg As String
Dim strSubject As String
Dim strPath As String
50 strToWhom = Me.CarriereMail
60 strWhere = "[CarrierID]=" & Me.CarrierID
70 strSubject = "Carrier Settlement"
80 strReportname = "CarrierSettlement"
90 strMsg = "Find attached latest Settlement Details"
100 If Dir("C:\Emails", vbDirectory) = "" Then MkDir "C:\Emails"
110 strPath = "C:\Emails\" & Format(Date, "mmddyyyy") & "- Carrier Settlement" & [LoadNumber] & ".pdf"
120 Set outApp = CreateObject("Outlook.Application")
130 Set outMail = outApp.CreateItem(0)
140 DoCmd.OpenReport "CarrierSettlement", acViewPreview
150 End If
160 With outMail
170 .To = strToWhom
180 .Subject = strSubject
190 .Attachments.Add strPath
200 .Body = strMsg
210 .Display
220 End With
230 On Error GoTo 0
240 Exit Sub
cmdPreview_Click_Error:
250 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdPreview_Click, line " & Erl & "."
End Sub
Attachments
Last edited: