VBA Send Object (1 Viewer)

cktcPeterson

Member
Local time
Today, 11:03
Joined
Mar 23, 2022
Messages
73
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
21,482
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)
 

cktcPeterson

Member
Local time
Today, 11:03
Joined
Mar 23, 2022
Messages
73
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?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
21,482
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.
 

cktcPeterson

Member
Local time
Today, 11:03
Joined
Mar 23, 2022
Messages
73
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
21,482
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

Top Bottom