shieldsco
asked on
Add Column Headings to HTML table
I'm trying to add column heading to the following HTML. The headings contained in the sbody1 are as follows Primary Appellant Full Name, Appeal Number and Adjudicator. This code is being run from an Access db that generates Outlook email with table.
sbody = "Hi " & strname & ",<br>The appeal(s) identified below are currently involved in the LA Initiative. Although the appeals have not been settled, the appeals have been pended in MAS. " & _
"<br><br>HA processing (i.e., conducting hearings and/or issuing orders) must cease until further notice from HA HQ. <b><u> DO NOT SHIP THE CASE FILE(S) TO THE Ad</b></u> You must keep possession of the case file(s) until further instruction from HA HQ." & sbody & "</table><br><br><br><br><br><table>" & sbody1 & " </table></b></i><br><br>If you have any questions, please let me know. Thank you!, </i></div></body></html>"
sbody1 = sbody1 & "</tr><td>" & rst2("Primary Appellant Full Name") & "<br></td><td>" & rst2("Appeal Number") & "<br></td><td>" & rst2("Adjudicator") & "</td></tr>"
Do yourself a favour and change the approach. Use templates, which then are filled by using Replace(). This way you can create your HTML content like a static web page.
ASKER
Next time... Don't have time to change now.. Thanks
???
15 minutes to craft this sample..
EE29090631.accdb
Option Compare Database
Option Explicit
Public Function GetTemplate(ATemplateID As Long) As String
GetTemplate = DLookup("TemplateText", "Templates", "TemplateID = " & ATemplateID)
End Function
Public Sub GenerateMail()
Const SQL_SELECT As String = _
"SELECT [Primary Appellant Full Name], [Appeal Number], [Adjudicator] " & _
"FROM Data;"
Dim rst2 As DAO.Recordset
Dim Body As String
Dim Rows As String
Set rst2 = CurrentDb.OpenRecordset(SQL_SELECT, dbOpenForwardOnly)
Do While Not rst2.EOF
Rows = Rows & GetTemplate(2)
Rows = Replace(Rows, "{Primary Appellant Full Name}", rst2![Primary Appellant Full Name])
Rows = Replace(Rows, "{Appeal Number}", rst2![Appeal Number])
Rows = Replace(Rows, "{Adjudicator}", rst2![Adjudicator])
rst2.MoveNext
Loop
Set rst2 = Nothing
Body = GetTemplate(1)
Body = Replace(Body, "{Rows}", Rows)
Debug.Print Body
End Sub
15 minutes to craft this sample..
EE29090631.accdb
ASKER
Thanks .... but I looking for solution to my code
This is the solution.
Especally as your HTML is pretty poor and hard to read, when embedded as string literals in VBA code. Cause now you can simply modify your template and add your headers.
Especally as your HTML is pretty poor and hard to read, when embedded as string literals in VBA code. Cause now you can simply modify your template and add your headers.
ASKER
I don't follow you... can you add example HTML that will work with my code
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your code is creating another table above my data table
ASKER
Made it work... thanks
ASKER
Thanks