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>"

Open in new window




   sbody1 = sbody1 & "</tr><td>" & rst2("Primary Appellant Full Name") & "<br></td><td>" & rst2("Appeal Number") & "<br></td><td>" & rst2("Adjudicator") & "</td></tr>"

Open in new window

shieldscoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
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.
0
shieldscoAuthor Commented:
Next time... Don't have time to change now.. Thanks
0
ste5anSenior DeveloperCommented:
???

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

Open in new window


15 minutes to craft this sample..
EE29090631.accdb
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

shieldscoAuthor Commented:
Thanks .... but I looking for solution to my code
0
ste5anSenior DeveloperCommented:
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.
0
shieldscoAuthor Commented:
I don't follow you... can you add example HTML that will work with my code
0
ste5anSenior DeveloperCommented:
Just change the template.

<html>
    <body>
        <p>Hi {strname}
        <p>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.
        <p>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><tr><th>Head 1</th><th>Head 2</th><th>Head 3</th></tr>{Rows}</table>
        <p>If you have any questions, please let me know. Thank you!
    </body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shieldscoAuthor Commented:
Your code is creating another table above my data table
0
shieldscoAuthor Commented:
Made it work... thanks
0
shieldscoAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.