customize an email subject line

W

wpshop

I am trying to customize the email subject line. Below is the code I am
using. I keep receiving a message "Object Required". I would appreciate any
assistance that can be provided. I'm not sure where I am going wrong.


Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stTo As String
Dim stSubject As String
Dim stText As String
Dim errLopp As String
Dim stAttachment As String

stTo = Nz(Form_frmEncorrChange_RequestMenuSwitchboard.BADSEmail, "")
stSubject = Nz(Report_rptLetterChangeRequest.BADSTrackingNumber, "")
stText = "This is a test of the emergency broadcast system. This is
only a test."
stAttachment = Report_rptLetterChangeRequest

DoCmd.SendObject acSendReport, "rptLetterChangeRequest", "Snapshot
Format", stTo, , , stSubject, stText, -1


Exit Sub

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub
 
T

Tom Wickerath

Try the following modifications to your code:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stTo As String
Dim stSubject As String
Dim stText As String
Dim stAttachment As String
Dim frm As Form

Set frm = [Forms]![frmEncorrChange_RequestMenuSwitchboard]

stTo = Nz([frm]![BADSEmail], "")
stSubject = Nz([frm]![BADSTrackingNumber], "")
stText = "This is a test of the emergency broadcast system. This is only a
test."

stAttachment = "rptLetterChangeRequest"

DoCmd.SendObject _
ObjectType:=acSendReport, _
ObjectName:=stAttachment, _
OutputFormat:="Snapshot Format", _
To:=stTo, Subject:=stSubject, _
MessageText:=stText, EditMessage:=True

Exit Sub

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub


Notes:
1.) Your form "frmEncorrChange_RequestMenuSwitchboard" must be open when you
run this code.

2.) I recommend renaming your command button to something a bit more
descriptive than "Command3".


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top