I can't get this code to send the report.
The code creates the report, but does not get past the send command. It never gets to the close report line.
If I modify the code to send a different report, it works fine.
The code creates the report, but does not get past the send command. It never gets to the close report line.
If I modify the code to send a different report, it works fine.
Code:
Private Sub cmdOrgPrint_Click()
Dim LResponse As Integer
Dim hours As Double
Dim name As String
Dim mailto As String
name = Left(Me.cmbWho, InStr(Me.cmbWho, " ") - 1) ' gets the first name
hours = Time() * 24 ' gets time
Dim str As String
' sets morning, afternoon or evening
If hours < 12 Then
str = "Good morning " & name & ","
ElseIf hours <= 17 Then
str = "Good afternoon " & name & ","
ElseIf hours > 17 Then
str = "Good evening " & name & ","
End If
subject = Me.Job.Column(0) & " " & Me.Job.Column(1) & " To Do Items For " & Me.cmbWho.Column(3)
emailmsg = str & vbCrLf & vbCrLf & "The attached report list various items that I am waiting a response from " & Me.cmbWho.Column(3) & "." _
& vbCrLf & vbCrLf & "Can you update me on the status of these items?" & vbCrLf & vbCrLf & Closing
' This sends the e-mail
Dim strWhere As String
mailto = Me.cmbWho.Column(2)
strWhere = "[Job]='" & Me.Job & "' And [Organization] ='" & Me.cmbWho.Column(3) & "'And [Open] = -1"
DoCmd.OpenReport "rptToDoList", acViewPreview, , strWhere
DoCmd.SendObject acSendReport, "rptToDoList", acFormatPDF, mailto, , , subject, emailmsg, True
DoCmd.Close acReport, "rptToDoList"
End Sub