I have the following code which creates a report, exports it then creates an e-mail based on what report you are sending. I am having problems with the EmailSend.to part of the code everytime I run it it comes back with the error
Runtime error '2465'
Energy Reports can't find the field 'Forms' referred to in your expression.
but that's not even a field in my expression, any ideas anyone
Thanks
Geoff
Dim EmailApp As Object
Dim NameSpace As Object
Dim EmailSend As Object
DoCmd.OutputTo acReport, "All_Direct_Reading_Sheets", "SnapshotFormat(*.snp)", "G:\E&S\Energy\em\Access_Reports\Meter_Reading_Sheet.snp", False, ""
Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)
EmailSend.to = DLookup("[E-Mail_Address_To]", "Report_Config", "[Lookup_Id]= '" & Me!Criteria_Selection & "'" And [Report_Group_No] = Me!Group_Selection And [Report_Type_No] = Me!Type_Selection) ' Put email address here
EmailSend.Subject = "Meter Reading Sheet - " & Me.Criteria_Selection
EmailSend.Body = "Dear " & DLookup("[E-Mail_Name_To]", "Report_Config", "[Lookup_Id]= '" & Me.Criteria_Selection & "'") & "," & Chr(13) & Chr(13) & "Please find attached this months Meter Reading sheet," & Chr(13) & Chr(13) & "Thanks" & Chr(13) & "Geoff" & Chr(13) & Chr(13) & "If you have problems viewing the attached file please install the viewer software attached, if you continue to have problems please contact, me on 57003" & Chr(13) & Chr(13)
EmailSend.Attachments.Add "G:\E&S\Energy\em\Access_Reports\Meter_Reading_Sheet.snp" ' Change this to match your path
EmailSend.Attachments.Add "G:\E&S\Energy\em\Data\Snapshot_Viewer.zip" ' Change this to match your path
EmailSend.Display ' Remove this line if you don't want to see email
Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing
Runtime error '2465'
Energy Reports can't find the field 'Forms' referred to in your expression.
but that's not even a field in my expression, any ideas anyone
Thanks
Geoff
Dim EmailApp As Object
Dim NameSpace As Object
Dim EmailSend As Object
DoCmd.OutputTo acReport, "All_Direct_Reading_Sheets", "SnapshotFormat(*.snp)", "G:\E&S\Energy\em\Access_Reports\Meter_Reading_Sheet.snp", False, ""
Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)
EmailSend.to = DLookup("[E-Mail_Address_To]", "Report_Config", "[Lookup_Id]= '" & Me!Criteria_Selection & "'" And [Report_Group_No] = Me!Group_Selection And [Report_Type_No] = Me!Type_Selection) ' Put email address here
EmailSend.Subject = "Meter Reading Sheet - " & Me.Criteria_Selection
EmailSend.Body = "Dear " & DLookup("[E-Mail_Name_To]", "Report_Config", "[Lookup_Id]= '" & Me.Criteria_Selection & "'") & "," & Chr(13) & Chr(13) & "Please find attached this months Meter Reading sheet," & Chr(13) & Chr(13) & "Thanks" & Chr(13) & "Geoff" & Chr(13) & Chr(13) & "If you have problems viewing the attached file please install the viewer software attached, if you continue to have problems please contact, me on 57003" & Chr(13) & Chr(13)
EmailSend.Attachments.Add "G:\E&S\Energy\em\Access_Reports\Meter_Reading_Sheet.snp" ' Change this to match your path
EmailSend.Attachments.Add "G:\E&S\Energy\em\Data\Snapshot_Viewer.zip" ' Change this to match your path
EmailSend.Display ' Remove this line if you don't want to see email
Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing