VBA Send Object (1 Viewer)

cktcPeterson

Member
Local time
Yesterday, 20:16
Joined
Mar 23, 2022
Messages
74
This is what I have:

Private Sub Command205_Click()

Dim sExistingReportName As String
Dim sAttachmentName As String

sExistingReportName = "rptApprovalEmailRC"
sAttachmentName = [Student Name] & " " & "Approval"

DoCmd.OpenReport sExistingReportName, acViewPreview, , , acHidden
Reports(sExistingReportName).Caption = sAttachmentName

DoCmd.SendObject acSendReport, sExistingReportName, acFormatPDF, , , , , , , True
End Sub

In the SendObject part, I want to add

=[Parent Email] -who it is going to.
=[Student Name] & " " & "Approval Letter-" & " "& [Course]-Subject
="Dear" & " " &[Parent Name] & " "& See attached approval letter for" & " "& [Student Name]-Message


Can someone help me add this in? I keep getting an error.
 
Have you tried?
Code:
DoCmd.SendObject acSendReport, sExistingReportName, acFormatPDF, Me.[Parent Email], , , Me.[Student Name] & " Approval Letter-" & Me.Course, "Dear " & [Me.Parent Name] & " See attached approval letter for " & Me.[Student Name], True
(untested - I hope I guessed the placements correctly)
 
Okay. one more question.

I need 1 more line of code at the end.
If I cancel my email, I get the debugger message. How to I omit that?
 
Okay. one more question.

I need 1 more line of code at the end.
If I cancel my email, I get the debugger message. How to I omit that?
You can add an Error Handler to handle the error.
 
I am not familiar with error handlers. Can some point me in the right direction? My error is that I canceled the send object command.
 
I am not familiar with error handlers. Can some point me in the right direction? My error is that I canceled the send object command.
Can you please post your entire code? Thanks.
 

Users who are viewing this thread

Back
Top Bottom