Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to populate the send to in auto report. 2

Status
Not open for further replies.

julius1

Technical User
Oct 31, 2002
142
US
Morning, I have a code set here that will enable me to send a doc by way of email and prompts users for format and then brings up the email all automatic. Is there anyway I can get it to populate with the send to and all they have to do is hit send?
Can this be referenced back to a macro? I can create that send doc in macro, but not sure how to link the 2 together. Any help would be appreciated thanks!

Private Sub Command12_Click()
On Error GoTo Err_Command12_Click

Dim strVal As String
strVal = Forms!TimeslotList!CircuitID
stDocName = "Circuit Timeslot List"
DoCmd.OpenReport "Circuit Timeslot List", acViewPreview, , "[Circuit ID]= '" & strVal & "'"
DoCmd.SendObject acSendReport, stDocName
DoCmd.Close acReport, "Circuit Timeslot List"

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub
Private Sub Command144_Click()
On Error GoTo Err_Command144_Click

Dim stDocName As String

stDocName = "TEST3"
DoCmd.SendObject acReport, stDocName

Exit_Command144_Click:
Exit Sub

Err_Command144_Click:
MsgBox Err.Description
Resume Exit_Command144_Click

End Sub
 
The SendObject Method is :

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, CC, BCC, Subject, MessageText, EditMessage, TemplateFile

Good Luck.
 
ok, I have no clue where i would add that into the script.
I see the send object, but not sure what to change out to be able to add an email address that will go to?
 
DoCmd.OpenReport "Circuit Timeslot List", acViewPreview, , "[Circuit ID]= '" & strVal & "'"
DoCmd.SendObject acSendReport, stDocName
DoCmd.Close acReport, "Circuit Timeslot List"

What is highlighted red is where you would enter it, for example

DoCmd.SendObject acSendReport, stDocName, , EmailAddress1, EmailAddress2
 
Cool i got it, worked like a charm!!!!!
Thanks!
 
Just curoius, hwo could I modify it so that it always send in rich text? I know it would be the output format, but I don't know how to write that in?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top