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

Adding new code to existing code for Email

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
The second piece of code below is what I currently have that picks up names
from TextBoxes and adds them to an email. I have found out that I also have
another field I need to pick up for this email. It is called Materials Distribution.
It is a ComboBox that only has one name in it. The name is Kim Dees. Her
email address is abkdees@nmhg.com. How can I get this added to the Email?

I tried this:
Code:
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Materials Distribution] = "Kim Dees" Then
toEmail1 = "abkdees@nmhg.com"
End If
But I do not know how to make it a part of the code below?

Code:
Dim x
Dim y
toEmail1 = ""
For Each x In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![Engineering Distribution] & "", vbCrLf)
  If Trim(x & "") > "" Then
    y = DLookup("LoginName", "FormEngMETbl", "EngME='" & x & "'")
    If Trim(y & "") > "" Then
      toEmail1 = toEmail1 & y & "@nmhg.com;"
    End If
  End If
Next
For Each x In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![Quality Distribution] & "", vbCrLf)
  If Trim(x & "") > "" Then
    y = DLookup("LoginName", "FormQAEngTbl", "QAEng='" & x & "'")
    If Trim(y & "") > "" Then
      toEmail1 = toEmail1 & y & "@nmhg.com;"
    End If
  End If
Next
For Each x In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![MasterSchedulerDistribution] & "", vbCrLf)
  If Trim(x & "") > "" Then
    y = DLookup("LoginName", "FormMasterSchedulerTbl", "MasterSchedulers='" & x & "'")
    If Trim(y & "") > "" Then
      toEmail1 = toEmail1 & y & "@nmhg.com;"
    End If
  End If
Next
 
toEmail1 = toEmail1 & "abkdees@nmhg.com"


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Ken,

I have not tried it yet but does that work even if the
[Materials Distribution] TextBox does not have Kim Dees in
it?
 
[Materials Distribution] TextBox does not have Kim Dees in
it?"

do you mean it is empty, or do you mean it may have someone elses name in it?

if you mean empty then

if len(trim([Materials Distribution])) > 0 then

toEmail1 = toEmail1 & "abkdees@nmhg.com"
end if

should do it, if you mean it may contain another persons name (and hence you need a different EMail address, That would be essentially the same as PHV has explained with ![MasterSchedulerDistribution].

The point I was trying to make in quoting the single line of code is that

toEmail1 = toEmail1 & "abkdees@nmhg.com"

essentially translates in human speak as take ToEMail1 and append to the end of it "abkdees@nmhg.com"

where as

toEmail1 = "abkdees@nmhg.com"

means overwrite the existing contents of toEMail1 (if any) with the value "abkdees@nmhg.com"


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Thanks Ken,

It will only have Kim Dees name it in if it has a name at
all. It might be empty.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top