weightinwildcat
Programmer
I am presently working on updating a form used to change requisition requests. When a change is made an email message is sent that gives information on the requisition and line items within the requisition. My supervisor wants future emails to show not only what values are entered, but what the old values are so people can see where a change has been made. What sort of syntax should my code have to make this possible?
Here is the code at present:
Dim rs As Recordset
Dim subRs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
Set subRs = Me.[REQITEM_TBL subform].Form.Recordset
EmailBody = "<div style='font-size:14px;'><h3>Req Info</h3>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>ReqID:" & _
"</td><td>" & Me.ReqID & _
"</td></tr><tr><td>User:" & _
"</td><td>" & Me.ReqUser & _
"</td></tr><tr><td>Req Type:" & _
"</td><td>" & Me.ReqTypeName & _
"</td></tr><tr><td>Active:" & _
"</td><td>" & Active & _
"</td></tr><tr><td>Req Date:" & _
"</td><td>" & Me.ReqDate & _
"</td></tr><tr><td>Need Date:" & _
"</td><td>" & Me.ReqNeedDate & "</td></tr></table></div>"
Do Until (subRs.EOF)
Dim count As Integer
count = 0 'index place holder used for display Header
'Loop through RS depending on amount of fields in RS
'Displays all fields and corresponding values
For Each field In subRs.fields
'FOV = field.OriginalValue
If (count = 0) Then
EmailBody = EmailBody & "<br/><h3>Req Items</h3><br/>"
count = count + 1
End If
'Displaying Req Item(s) details
'EmailBody = EmailBody & "<br/>" & field.Name & ": " & field.Value & vbCrLf
'EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td></tr></table>"
'EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td>" & _
"<td>" & FOV & "</td></tr></table></div>"
EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td></tr></table></div>"
'EmailBody = EmailBody & "</table></div>"
Next
'Next record
subRs.MoveNext
Loop
Call SendEmail(emailTo, emailCC, EmailSubject, Null, EmailBody)
Here is the code at present:
Dim rs As Recordset
Dim subRs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
Set subRs = Me.[REQITEM_TBL subform].Form.Recordset
EmailBody = "<div style='font-size:14px;'><h3>Req Info</h3>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>ReqID:" & _
"</td><td>" & Me.ReqID & _
"</td></tr><tr><td>User:" & _
"</td><td>" & Me.ReqUser & _
"</td></tr><tr><td>Req Type:" & _
"</td><td>" & Me.ReqTypeName & _
"</td></tr><tr><td>Active:" & _
"</td><td>" & Active & _
"</td></tr><tr><td>Req Date:" & _
"</td><td>" & Me.ReqDate & _
"</td></tr><tr><td>Need Date:" & _
"</td><td>" & Me.ReqNeedDate & "</td></tr></table></div>"
Do Until (subRs.EOF)
Dim count As Integer
count = 0 'index place holder used for display Header
'Loop through RS depending on amount of fields in RS
'Displays all fields and corresponding values
For Each field In subRs.fields
'FOV = field.OriginalValue
If (count = 0) Then
EmailBody = EmailBody & "<br/><h3>Req Items</h3><br/>"
count = count + 1
End If
'Displaying Req Item(s) details
'EmailBody = EmailBody & "<br/>" & field.Name & ": " & field.Value & vbCrLf
'EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td></tr></table>"
'EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td>" & _
"<td>" & FOV & "</td></tr></table></div>"
EmailBody = EmailBody & "<div style='font-size:14px;'>" & _
"<table border='1' padding='2px 2px 2px 2px;'><tr><td>" & _
field.Name & "</td><td>" & field.value & "</td></tr></table></div>"
'EmailBody = EmailBody & "</table></div>"
Next
'Next record
subRs.MoveNext
Loop
Call SendEmail(emailTo, emailCC, EmailSubject, Null, EmailBody)