Hello -
I'm using a Do Until loop that is basically writing the body text of an email for me. It's working great, but I need to add one more thing.
It is storing the Body text that it is creating as a BodyText string within the loop. Works good. However, I really need the Body text variable to increment each time the loop is ran, or the loop becomes pointless.
Example:
User enters 5 form entries.
User hits 'Send Email'
VBA runs code to build email for each entry submitted
VBA sends the full body text of all 5 form entries to Lotus Notes (-_-)
Here is the code I'm using, slightly modified for better viewing:
After this, there is code that generates email. The probelm I'm having is that the BodyText variable is only remembering one loop. I need a way (array?) to name BodyText within in the loop so that each form entry text that is built has a different name and can be combined, i.e. Body1, Body2, Body3.
EDIT: I use the email code to call/instert 'BodyText'. So I would want to define BodyText = Body1 & Body2 & Body3 & Body4, etc. so that each record that went through the loop appears in the email.
Thanks!
I'm using a Do Until loop that is basically writing the body text of an email for me. It's working great, but I need to add one more thing.
It is storing the Body text that it is creating as a BodyText string within the loop. Works good. However, I really need the Body text variable to increment each time the loop is ran, or the loop becomes pointless.
Example:
User enters 5 form entries.
User hits 'Send Email'
VBA runs code to build email for each entry submitted
VBA sends the full body text of all 5 form entries to Lotus Notes (-_-)
Here is the code I'm using, slightly modified for better viewing:
Code:
'Perform a Do Until loop to build the email with multiple policies
Dim r As DAO.Recordset
Dim rcount As Integer
Set r = CurrentDb.OpenRecordset("SELECT * FROM " & Me.User.Value & "")
r.MoveLast
rcount = r.RecordCount
If rcount > 0 = True Then
r.MoveFirst
Do Until r.EOF = True
'Save policy number and Body into a variable
Dim sPolicy As String
sPolicy = r!Policy
'Build body text strings for each policy
'Me.RLCEmail.Value = DLookup("RLCEmail", "tblRLCrelationships", "RLC='" & Me.RLC.Value & "'")
Dim sNEW As String
Dim sAOR As String
Dim sSDR As String
Dim sPREM As String
Dim sALR As String
Dim sRM As String
Dim sRMDESC As String
Dim sAPS As String
Dim APSDESC As String
Dim sM1035 As String
Dim sN1035 As String
Dim sMNAIC As String
Dim sNNAIC As String
Dim sRDESC As String
Dim sNAN As String
Dim sNANDESC As String
Dim sMISC1 As String
Dim sMISC2 As String
Dim sMISC3 As String
Dim sBWP As String
Dim sCOD As String
[BUILDING OF BODY TEXT REMOVED FOR BREVITY]
Dim BodyText As String
BodyText = sNEW & sAOR & sSDR & sPREM & sALR & sRM & sRMDESC & sAPS & APSDESC & sM1035 & _
sN1035 & sMNAIC & sNNAIC & sRDESC & sNAN & sNANDESC & sMISC1 & sMISC2 & sMISC3 & _
sBWP & sCOD
'Move to the next record. Don't ever forget to do this.
r.MoveNext
Loop
Else
End If
r.Close
Set r = Nothing
After this, there is code that generates email. The probelm I'm having is that the BodyText variable is only remembering one loop. I need a way (array?) to name BodyText within in the loop so that each form entry text that is built has a different name and can be combined, i.e. Body1, Body2, Body3.
EDIT: I use the email code to call/instert 'BodyText'. So I would want to define BodyText = Body1 & Body2 & Body3 & Body4, etc. so that each record that went through the loop appears in the email.
Thanks!
Last edited: