Hello,
I know nothing about code so please forgive me if I do not make sense or if this is a simple fix. I have been trying to muddle my way through updating an Access database form. The creator is no longer in our work unit and no one knows how to change things. We recently sunsetted a rewards program that was logged through this database and I am trying to make changes to fit the new program. In the past you could only choose one person as the "From" but we often get submissions with multiple "From" and want to reflect this in the email that is auto generated. There is already a piece in the code that operates the way we want this to. The part for "Me.lstTechAdded.Column(2, i)" will send the email to multiple recipients but I cannot figure out how to make the "Me.techadd.Column" do the same thing. I have changed the text to red in the code that contains the portion I am trying to figure out.
If someone has time I would greatly appreciate help on this!
I know nothing about code so please forgive me if I do not make sense or if this is a simple fix. I have been trying to muddle my way through updating an Access database form. The creator is no longer in our work unit and no one knows how to change things. We recently sunsetted a rewards program that was logged through this database and I am trying to make changes to fit the new program. In the past you could only choose one person as the "From" but we often get submissions with multiple "From" and want to reflect this in the email that is auto generated. There is already a piece in the code that operates the way we want this to. The part for "Me.lstTechAdded.Column(2, i)" will send the email to multiple recipients but I cannot figure out how to make the "Me.techadd.Column" do the same thing. I have changed the text to red in the code that contains the portion I am trying to figure out.
If someone has time I would greatly appreciate help on this!
Rich (BB code):
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)
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(3) & " </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 = "DLHCLLabMgmt@exchange.mayo.edu; " & 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