I am trying to take data from a subform to include it in an email. It works fine when only referring as such [subform]![field] but then it only shows the first line of the subform records.
Does anyone know how to include all records from the subform?
This is what I have to date:
Does anyone know how to include all records from the subform?
This is what I have to date:
Code:
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'**************************************************************
'*create string with email address
strEmail = Text85
strBody = strBody & "We are please to announce your order has been shipped. Below you will find the appropriate" & _
" shipment details. For more information please contact customer service." & Chr(13) & Chr(13) & Chr(13)
strBody = strBody & "Date Shipped: " & Date & Chr(13)
strBody = strBody & "Carrier Name: " & CarrierName & Chr(13)
strBody = strBody & "Customer Order Ref: " & CustomerOrder & Chr(13)
strBody = strBody & "Ref Number: " & OurOrder & Chr(13)
strBody = strBody & "Delivery Instructions and Other Pertinent Information: " & Instructions & Chr(13) & Chr(13)
strBody = strBody & "BOL Line Details: " & [tblShipmentDetails subform]![detQTY] & [tblShipmentDetails subform]![detUnitQty] & Chr(13) & Chr(13)
strBody = strBody & "Sincerely," & Chr(13) & Chr(13)
strBody = strBody & "shipping department."
'***creates and sends email
With objEmail
If Not IsNull(Text85) Then
.To = strEmail
End If
.Subject = "SHIPMENT NOTIFICATION"
If Not IsNull(Text87) Then
.CC = (Text87)
End If
.Body = strBody
If Not IsNull(Text85) Or Not IsNull(Text87) Then
.Send
End If
End With
Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
'objOutlook.Quit
Exit Sub