L
Luiz Gustavo de Moraes
Hi, I'm sending a report by MS Outlook2002 using docmd.sendobject. I give
an option to the user by means of a msgbox, this msgbox allows the user to
send the report via email or just to view the report. If the user hits "YES"
the report is transformed into a RTF document and automatically sent, if
"CANCEL" is hit only the report appears. The problem is: If the user press
YES (to sent the report via email) and after the Outolook session opens and
the email is created he closes this email, he gets a run-time error message
saying that the macro was canceled. How Can I treat this kind of error?
Please refer to the code:
Private Sub cmdPrintRecord_cons_Click()
Dim strReportName2 As String
Dim strCriteria, response As String
strReportName2 = "rptPrintReport_RDV"
strCriteria = "[Código]=" & Me![Código] & ""
DoCmd.OpenReport strReportName2, acViewPreview, , strCriteria
response = MsgBox("Send form via e-mail?", vbOKCancel)
If response = vbOK Then
DoCmd.SendObject acSendReport, strReportName, acFormatRTF,
"(e-mail address removed)", , "(e-mail address removed)", "Sending form # " & " " &
Me!
an option to the user by means of a msgbox, this msgbox allows the user to
send the report via email or just to view the report. If the user hits "YES"
the report is transformed into a RTF document and automatically sent, if
"CANCEL" is hit only the report appears. The problem is: If the user press
YES (to sent the report via email) and after the Outolook session opens and
the email is created he closes this email, he gets a run-time error message
saying that the macro was canceled. How Can I treat this kind of error?
Please refer to the code:
Private Sub cmdPrintRecord_cons_Click()
Dim strReportName2 As String
Dim strCriteria, response As String
strReportName2 = "rptPrintReport_RDV"
strCriteria = "[Código]=" & Me![Código] & ""
DoCmd.OpenReport strReportName2, acViewPreview, , strCriteria
response = MsgBox("Send form via e-mail?", vbOKCancel)
If response = vbOK Then
DoCmd.SendObject acSendReport, strReportName, acFormatRTF,
"(e-mail address removed)", , "(e-mail address removed)", "Sending form # " & " " &
Me!
Code:
+ 1000, "This email has the purpose of notification only"
End If
Exit_cmdPrintRecord_cons_Click:
Exit Sub
Err_cmdPrintRecord_cons_Click:
MsgBox Err.Description
Resume Exit_cmdPrintRecord_cons_Click
End Sub
Thanks in advance