Hello! I know little to nothing about code and what I have figured out I did by trial and error after a lot of googling. I am trying to update a form created for tracking our employee appreciation program. In the image below there is a box where I wrote "Name 1" and "Name 2" and this box is "techadd" in the code. The code will already generate an email when the "Save/Email" button is clicked and use multiple names from the second box which is "lstTechAdded" in the code. What I have managed to do so far is get the email to generate with "Name 2" in the CC section and in the Body From section but not "Name 1". If anyone can give my direction on how to extract more than one name from this cell to the cc and from in the email I would greatly appreciate it!!!
forum.ozgrid.com/index.php?attachment/1232469/
Private Sub btnSave_Click()
If IsNull(Me.txtDate) = True Or Me.txtDate = "" Then
MsgBox ("Fill in the Date")
Exit Sub
End If
If Not Me.techadd.ListCount > 0 Then
MsgBox ("Please add at least one tech to the Tech(s) From box")
Exit Sub
End If
If IsNull(Me.txtInfo) = True Or Me.txtInfo = "" Then
MsgBox ("Fill in the Recognition Info box")
Exit Sub
End If
If Not Me.lstTechAdded.ListCount > 0 Then
MsgBox ("Please add at least one tech to the Tech(s) To box")
Exit Sub
End If
Dim dbs As DAO.Database
Dim strSql As String
Dim strAddresses As String
Dim strSubject As String
Dim strBody As String
Dim strCC As String
Set dbs = CurrentDb
strAddresses = ""
For i = 0 To Me.lstTechAdded.ListCount - 1
strSql = "INSERT INTO tblPeachEntry " & _
"(peachTechID, peachDate, peachTechFromID, peachInfo) " & _
"VALUES (" & Me.lstTechAdded.ItemData(i) & ", #" & Me.txtDate & "#, " & Me.techadd.ItemData(i) & ", '" & Replace(Me.txtInfo, "'", "''") & "');"
dbs.Execute (strSql)
If strAddresses = "" Then
strAddresses = Me.lstTechAdded.Column(2, i)
Else
strAddresses = strAddresses & "; " & Me.lstTechAdded.Column(2, i)
End If
Next
'New html email body
strCC = "DL RST HCL Management;" & Me.techadd.Column(2, i)
strSubject = "You are Awesome!"
strBody = "<html><body><p style='font-family: Calibri;font-size:18px;'>You received <b style='color:#F79646;'>Stronger Together recognition!</b><br><br>" & _
"It's from <b> " & Me.techadd.Column(0, i) & " </b> and it says: <br><br> '" & Me.txtInfo & "'" & _
"<br><br>Thank you for being awesome and a valued member of our team! </p></body></html>"
CreateEmail strAddresses, strSubject, strBody, False, strCC
ClearForm
Set dbs = Nothing
'**old email body
'Edit Email Subject and body here... VbCrLf = line feed **old email body
'strCC = "[email protected]; " & Me.techadd.Column(2)
'strSubject = "You are Awesome!"
'strBody = "You received recognition from " & Me.techadd.Column(3) & vbCrLf & vbCrLf & _
'"Reason: " & Me.txtReason & vbCrLf & vbCrLf & _
'"Description: '" & [Me.txtInfo] & "'"
'CreateEmail strAddresses, strSubject, strBody, strCC
End Sub
Display More