Last lin at the green &. I could make it go to the first .Subject line if I didn't have any data, but it would stop at the &. I put a ' at that string to let it bypass the .Subject line. That it did fine. but it halted at the next & with the Type mismatch fault on the next instance:
DoCmd.OutputTo 3, "Daily Actions", acFormatPDF, "C:\Temp\Daily Actions - " & Format(Date, "dd mmm yyyy") & ".pdf", , 0
This site has helped me a lot, and I have adapted some code to my own needs. I am still new to the coding world.
Code:
Public Sub Send_Daily_Click()
On Error GoTo ErrorMsgs
Dim rs As Dao.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookMsg1 As Outlook.MailItem
Dim objOutlookMsg2 As Outlook.MailItem
Dim objOutlookAttach As Outlook.Attachment
Dim strBody, strAddresses, strSubject, strMsg As String
Dim CRNUM, DateTypes, FINAL As Variant
Set rs = CurrentDb.OpenRecordset("SELECT Status,CR_Numbers,[Change Requested]FROM Daily_Actions_Email ORDER BY Status,CR_ID ASC")
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set objOutlookMsg1 = objOutlook.CreateItem(olMailItem)
Set objOutlookMsg2 = objOutlook.CreateItem(olMailItem)
CRNUM = DLookup("[CR_Numbers]", "[Daily_Actions_Email]")
DateTypes = DLookup("[DateType]", "[Settings_Qry]")
FINAL = DLookup("[Final_Vote]", "[Daily_Actions_Email]")
With DoCmd
.SetWarnings False
.OpenQuery "Daily Update"
.SetWarnings True
End With
If IsNull(CRNUM) Then
With objOutlookMsg
.Subject = "There were no actioned CR's - " & Format(Date, "dd mmm yyyy")
.Body = "The email addressing is a living entity. If there are corrections, additions, or deletions, please notify the sender." & vbCrLf & vbCrLf & _
"There were no actioned Change Requests for " & Format(Date, "dd mmm yyyy") & "." & strSigBlock
.To = "CCB Results"
.Display
DoCmd.Close acReport, "Daily Actions"
Exit Sub
End With
Else
End If
rs.MoveFirst
While Not rs.EOF
strMsg = strMsg & rs!Status & vbCrLf & Chr(9) & "CR " & rs!CR_Numbers & " - " & rs![Change Requested] & vbCrLf
rs.MoveNext
Wend
rs.Close
With objOutlookMsg1
.Subject = "Today's AORB/TEWG/CCB outcome - " & strTod ' Format(Date, "dd mmm yyyy")