VBA Help Needed

AmandaZ

New Member
Joined
Aug 13, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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!




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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top