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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCm. SendObject: Email To: Depends on Combo Box Selection but I can't get it to work

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
My DoCmd.SendObject to send a report in PDF to selected individuals. And it works if I type in the email address into the DoCmd.SendObject code. However, I need my form to select the "To:" person with a Combo control. The Combo control then holds the correct email address.

In the DoCmd.SendObject I have tried several items in the space reserved for "To:" Me.EmailDD "Me.EmailDD", [EmailDD], and "[EmailDD]"

Nothing works. The code is run by a command button on the Form that contains the Combo control (EmailDD)

The form name is "IPSS Open Courses"without the quotes.

Code:
DoCmd.SendObject acSendReport, "EOC Sheet rpt", acFormatPDF, [COLOR=#EF2929]"I need the EmailDD value here"[/color], , , "Class EOC", "You can use this form to print the number of copies you need." & Chr(10) & Chr(10) & "Thanks." & Chr(10) & "John J. Schreiber", False

Please: Where am I going wrong.

Thanks

John
 
Based on this article, I would do:

Code:
Dim strName As String
Dim strTo As String 

strName ="EOC Sheet rpt"
strTo = Me.EmailDD

DoCmd.SendObject acSendReport, strName, acFormatPDF, strTo, , , "Class EOC", "You can use this form to print the number of copies you need." & Chr(10) & Chr(10) & "Thanks." & Chr(10) & "John J. Schreiber", False

You can see the approach. This way you can easily evaluate what values you use for any parameter of DoCmd.SendObject


---- Andy

There is a great need for a sarcasm font.
 
Thanks Andy, I will give that a try. I understand the strTo part. Why is the strName for?

Thanks,
John
 
strName - That's the name of your report, isn't it [ponder]
I would also introduce: strSubject, strBody, etc.

Code:
Dim strName As String
Dim strTo As String 
Dim strSubject As String
Dim strBody As String

strName ="EOC Sheet rpt"
strTo = Me.EmailDD
strSubject = "Class EOC"
strBody = "You can use this form to print the number of copies you need." & Chr(10) & Chr(10) & "Thanks." & Chr(10) & "John J. Schreiber"

DoCmd.SendObject acSendReport, strName, acFormatPDF, strTo, , , strSubject, strBody, False

---- Andy

There is a great need for a sarcasm font.
 
Andy, that worked fine. Now I need to add a little twist to my question. I actually need to send the email to two places. With the strEmailDD you solved one. This was based on a selection that could be different every time, on the form. But, I need to send the same email to a group in box, we will call it xyz@boeing.com. The emails go to this group in addition to the strEmailDD every time. I tried several ways to incorporate this into to the To: along with the strEmailDD and have been unsuccessful. My fall back is to CC xyz@boeing.com. This works...but I would really like to know how to add it to strEmailDD in the To: space.

Can you help with this also?

Thanks again,

John
 
I would try:

Code:
...
Private Const BOENING As String = "xyz@boeing.com"
...
strTo = Me.EmailDD & ";" & BOENING
...

Or whatever you need to use to separate e-mail addresses.



---- Andy

There is a great need for a sarcasm font.
 
Andy, thanks for the feedback. I think I tried that but I am not sure. I will try it.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top