Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 38
  1. #16
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Thanks Vlad, WGM, i will come back to this a little later today, i want to check what you have suggested and compare, not had a great afternoon with my diabetes, low sugar

    Come back soon, kindest to you all

  2. #17
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Hi Vlad, just tried to test Tuesday, still not getting blank row after each driver, i liked WGM method of setting strBlankLine as String, i think im not understanding what to add as blank line

    i also assumed ending if after strbody2 ? thought i needed to terminate the if after strbody2 data..

    Code:
    strBlankLine = "<tr></tr>"
    
    strHTML2 = "<HTML><Body><table border='3' width=auto'><font color='blue' size='3' face='Arial'><tr><th>Day</th><th>Delivery Date</th></th>" & _
            "<th>Driver</th><th>Delivery To (In Order)</th><th>Town</th><th>PostCode</th><tr>"
        
              strBody2 = strHTML2
            
        strSQL2 = "SELECT tblRoutes.DayName, tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo, tblRoutes.DelTo, tblRoutes.Town, tblRoutes.PostCode, tblRoutes.ETA, tblRoutes.Source " _
            & "From tblRoutes " _
            & "WHERE (((tblRoutes.DayName)= ""Tuesday"")) " _
            & "ORDER BY tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo;"
            
        Set rs2 = CurrentDb.OpenRecordset(strSQL2)
    
    
           'VLAD -set initial value for sCurrentDriver
        If rs.RecordCount > 0 Then sCurrentDriver = rs2("Driver") 'first record of recordset ordered by driver
        
        Do While Not rs2.EOF
        
        If IsNull(rs2.Fields("DayName")) Then
            sDayName = "No Date Planned"
        Else
            sDayName = rs2.Fields("DayName")
        End If
        
        If sCurrentDriver <> rs2("Driver") Then
                'VLAD driver changed -insert blank line here
                strBlankLine = strBlankLine' Tried This
                strBlankLine ' Tried This        
        End If
            
        strBody2 = strBody2 & "<tr>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & sDayName & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & Format(rs2.Fields("DelDate"), "dd-mmm-yyyy") & strFE & "</td>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & rs2.Fields("Driver") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("DelTo") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("Town") & strFE & "</td>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & rs2.Fields("PostCode") & strFE & "</td></tr>" & "|"
        
        
            sCurrentDriver = rs2("Driver") 'Vlad -reset variable
        rs2.MoveNext
        Loop

  3. #18
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    I used to have a copy of Access Developer's Handbook 2003, and in it, there was code that pretty much did this... took the results from a query, and converted those results to an HTML table. For starters, they used ADO instead of DAO (maybe because it was easier to do using ADO?). You could create a function in Access that basically receives a table or select query object (ReturnsRecords property = True), and then loop over that and turn that into a delimited string. (I know you can... I did it like 15 years ago, but a lot of water has gone under the bridge since then!) Then you drop that into Word or Outlook and convert that delimited string into a table and you're finished.

  4. #19
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Dave,
    Have you tried this?
    Code:
    If sCurrentDriver<>rs("Driver") Then 
    'VLAD driver changed -insert blank line here
        strBody=strBody & vbCrLF
    End if
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #20
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    438
    try this code and also add another sub to your code:
    Code:
    Dim myApp As New Outlook.Application, outAccount As Outlook.Account, myItem As Outlook.MailItem
    Dim oOutlook As Object
    
    
    Dim dtStart As Date, dtEnd As Date, dtShipDate As Date
    Dim sSmiley As String, TimeNow As Integer
    Dim strFS As String, strFE As String, TOD As String
    Dim i As Integer, myMonth As Integer, SigFile As String
    Dim eDisc As String, eDisc2 As String, strUser As String
    Dim FullUser As Variant, strfName As String, strSign As String
    Dim strUserSign As String, strMSG As String, myGreet As String
    Dim strBody As String, strEmail, sCC As String, sCC2 As String, sCC3 As String, sCC4 As String
    Dim strCCAll As String
    Dim varOpt As Variant
       
        sSmiley = "<span style='font-size:16px;'>??</span>"
        
        strFS = "<font size='3' face='Arial' style=text-align=center; vertical-align=middle>" ' Mail Font
        strFE = "</font>" ' End Font’
        '*for testing only
        'dtShipDate = #2/1/2025#
        'dtStart = #2/3/2025#
        'dtEnd = #2/7/2025#
        
        dtShipDate = Format(Me.cboWeek, "mm/dd/yyyy")
        dtStart = DateAdd("d", 3, Me.cboWeek)
        dtEnd = DateAdd("d", 9, Me.cboWeek)
     
    TimeNow = Hour(Now())
        Select Case TimeNow
        Case Is <= 12
            TOD = strFS & "Good Morning ," & "hope you are well " & strFE & sSmiley
        Case Is <= 17
            TOD = strFS & "Good Afternoon ," & "hope you are well " & strFE & sSmiley
        Case Else
            TOD = strFS & "Good Evening ," & "hope you are well " & strFE & sSmiley
        End Select
     
     
    myMonth = Month(Now())
    If myMonth < 12 Then
        SigFile = "DMT dave@ Email Signature.jpg"
    Else
        SigFile = "DMT Xmas Signature.jpg"
    End If
     
    eDisc = "This Is Our Email Disclaimer"
    eDisc2 = "“This Is Our Email Disclaimer2”"
     
    strUser = Forms!frmMainMenu!txtLogin
    '*for testing only
    'strUser = "arnel puzon"
    
    
    FullUser = Split(strUser, " ")
    strfName = FullUser(0)
    strSign = strUser
     
    strUserSign = "<i><font face='Bradley Hand TC' size='4'>" & strSign & "</font></i>"
       
    strMSG = "WEEKLY PLANNER.|" & _
        "DMT delivery plans for week commencing " & Format(dtStart, "dddd-dd-mmm-yyyy") & ".|" & _
        "Please note, plans throughout the week may well change.|"
       
    myGreet = TOD
     
           
        strBody = "<HTML><Body>"
        
        Dim iDay As Integer
        For iDay = 2 To 6
            Call AppendToBody(WeekdayName(iDay, False, vbSunday), strBody)
        Next
       
       
        strEmail = "driver1mail"
        sCC = " driver2mail "
        sCC2 = " driver3mail "
        sCC3 = " driver4mail "
        sCC4 = " driver5mail "
       
        strCCAll = sCC & "; " & sCC2 & " ;" & sCC3 & ": " & sCC4
     
      Set myItem = myApp.CreateItem(olMailItem)
        Set outAccount = myApp.Session.Accounts.Item(1)
        With myItem
            .To = strEmail
            .CC = strCCAll
        .Subject = "Week Commencing " & Format(dtStart, "dd-mmm-yyyy")
        
        .HTMLBody = strFS & myGreet & "<br>" & "<br>" & Replace(strMSG, "|", "<br>" & "<br>") & strFE & "<br>" & "<br>" & _
        strBody & _
        strUserSign & "<br>" & "<br>" & _
        "<P><IMG border=0 hspace=0 alt='' src='file://T:/DMT Ltd/Logo Media/" & SigFile & "' align=baseline></P>" & "<br>" & "<br>" & _
        "<FONT color=#00008B>" & eDisc & "<br>" & "<FONT color =#00008B>" & eDisc2
        .SendUsingAccount = outAccount
        .Display
    End With
    ...
    ...
    ...
    Code:
    Private Sub AppendToBody(ByVal strDay As String, ByRef strBody As String)
        Dim rs As DAO.Recordset
        Dim thisDriver As Variant
        Dim sql As String
        Dim sFH As String, sFHEnd As String
        Dim strBoxStart As String, strBoxEnd As String
        Dim strFS As String, strFE As String
        Dim sDayName As String
        Dim blankRow As String
        
        'blankRow = "<tr><td colspan='6'>&nbsp;</td></tr>"
        blankRow = "<tr style='height: 5px;'>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "</tr>"
        strFS = "<font size='3' face='Arial' style=text-align=center; vertical-align=middle>" ' Mail Font
        strFE = "</font>" ' End Font’
        
        strBoxStart = "<script><table width='auto';style='text-align:left;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'><tr style='background:white;mso-highlight:blue' ctx.shadowblur;20; ctx.shadowcolor;blue></script>"
        strBoxEnd = "</tr></table>"
        
        sFH = "<font size='4' face='Verdana' style=text-align=center; vertical-align=middle>"
        sFHEnd = "</font>"
        
        strBody = strBody & sFH & "<B>" & strDay & "</B>" & sFHEnd & "<br>" & strBoxStart
        strBody = strBody & _
        "<table border='3' width=auto'><font color='blue' size='3' face='Arial'><tr><th>Day</th><th>Delivery Date</th></th>" & _
        "<th>Driver</th><th>Delivery To (In Order)</th><th>Town</th><th>PostCode</th><tr>"
        
        sql = "SELECT tblRoutes.DayName, tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo, tblRoutes.DelTo, tblRoutes.Town, tblRoutes.PostCode, tblRoutes.ETA " _
            & "From tblRoutes " _
            & "WHERE (((tblRoutes.DayName)= '" & strDay & "')) " _
            & "ORDER BY tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo;"
            
        With CurrentDb.OpenRecordset(sql, dbOpenSnapshot, dbReadOnly)
            If Not (.BOF And .EOF) Then
                .MoveFirst
                thisDriver = !driver
            End If
            Do While Not .EOF
                If IsNull(!DAYNAME) Then
                    sDayName = "No Date Planned"
                Else
                    sDayName = !DAYNAME
                End If
       
                strBody = strBody & "<tr>" & _
                    "<td style='background-color:#F5F5F5'>" & strFS & sDayName & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF'>" & strFS & Format$(!DelDate, "dd-mmm-yyyy") & strFE & "</td>" & _
                    "<td style='background-color:#F5F5F5'>" & strFS & !driver & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF'>" & strFS & !DelTo & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF'>" & strFS & !Town & strFE & "</td>" & _
                    "<td style='background-color:#F5F5F5'>" & strFS & !PostCode & strFE & "</td></tr>"
           
                .MoveNext
                If Not .EOF Then
                    If !driver & "" <> thisDriver Then
                        thisDriver = !driver & ""
                        strBody = strBody & blankRow
                    End If
                End If
            Loop
            .Close
        End With
        strBody = strBody & "</table>" & strBoxEnd & "<br>"
            
    End Sub
    Click image for larger version. 

Name:	sample_outlook.png 
Views:	12 
Size:	83.4 KB 
ID:	52717

  6. #21
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    @ Vlad, yes i did try that and still doesn't add the blank line, however when i read what i was trying, i guess where i was wrong is trying add a HTML element outside of the HTML table, instead of vb ? such as <tr> or <br> etc instead of vbCrlf

    @jojowhite, that result is the one, i have modules called Public Subs and Public Functions, would i place your (Append To Body) in a module ? then run the Sub from an option / check / button ? current using option, i do like using option unless there is a large list of options then lists / combos

    If a simple yes or no then i like it as its easy to say case false is exit sub case else proceed

    I think your kind input goes to what Vlad was saying regarding stream line the full procedure

    @ Vlad, as mentioned above, i tried changing to

    Code:
        Set rs2 = CurrentDb.OpenRecordset(strSQL2)
    
           'VLAD -set initial value for sCurrentDriver
        If rs.RecordCount > 0 Then sCurrentDriver = rs2("Driver") 'first record of recordset ordered by driver
        
        Do While Not rs2.EOF
        
        If IsNull(rs2.Fields("DayName")) Then
            sDayName = "No Date Planned"
        Else
            sDayName = rs2.Fields("DayName")
        End If
        
        If sCurrentDriver <> rs2("Driver") Then
                'VLAD driver changed -insert blank line here
                strBody = strBody & vbCrLf
            
        End If
            
        strBody2 = strBody2 & "<tr>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & sDayName & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & Format(rs2.Fields("DelDate"), "dd-mmm-yyyy") & strFE & "</td>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & rs2.Fields("Driver") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("DelTo") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("Town") & strFE & "</td>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & rs2.Fields("PostCode") & strFE & "</td></tr>" & "|"
        
        
            sCurrentDriver = rs2("Driver") 'Vlad -reset variable
        rs2.MoveNext
        Loop
    Still doesn't generate a new line!!

  7. #22
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    since you're talking about an HTML table, don't you mean a blank row in the table?

    if that's the case then you'd need to append another row to strBody2... something like

    strBody2 = strBody2 & "<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>"

    and then later you'd have to "close" the table

    strBody2 = strBody2 & "</table>" (well, outside of the rs2 loop).

  8. #23
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    438
    first replace your code (in post #11) with the the first code i posted.
    then on the same Module, copy and paste the the AppendToBody() sub.
    test your email routine (I think from your form?)

  9. #24
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Sorry jojowhite, when you say on the same module for 2nd code (AppendToBody), that goes above the 1st code in the Sub control (Button - Combo) OR in a Module, i think you refer to control on the form so they both go on the same procedure ?

    Sorry i have misunderstood the 2nd part!!

  10. #25
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    WOW, i understood now what you meant, the Append To Body is a new Sub, i pasted above the first code, no wonder i call everyone on here a genius, that has certainly given the result.

    PS: i have never added a new Sub like that before, always thought to use from a Module then call it when required!!

    That has certainly done the trick and when i get time later on, i really want to analyse this method

    Thanks to you all, everyday is a school day and it's a matter of breaking down your method and making notes of it so i can understand it better..........................

  11. #26
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    438
    if you will notice on the output (outlook mail), that sometimes the Tables are not of
    "uniform" width (some maybe wide than the others).
    to make them uniform, replace the code from AppendToBody() sub:
    Code:
        strBody = strBody & _
        "<table border='3' width=auto'><font color='blue' size='3' face='Arial'><tr><th>Day</th><th>Delivery Date</th></th>" & _
        "<th>Driver</th><th>Delivery To (In Order)</th><th>Town</th><th>PostCode</th><tr>"
    With:
    Code:
        strBody = strBody & _
        "<table width='90%' border='3' width=auto'><font color='blue' size='3' face='Arial'><tr><th>Day</th><th>Delivery Date</th></th>" & _
        "<th>Driver</th><th>Delivery To (In Order)</th><th>Town</th><th>PostCode</th><tr>"
    you can also make the "width" 100%. meaning the table width is same as the Outlook Window width.

  12. #27
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    jojowhite, yes i see what you mean by adding table width pre table border, i will have a play around with it a little later but i am intrigued by adding a sub (probably never to be clicked on) just called on (not in a module)

    Thanks again, i guess i can play about with text, table, border sizes and styles etc.....

  13. #28
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    jojowhite, if i wanted to be even cleaner or a clever cloggs and fill the blank rows in with ie: grey, where in the blank row code would i add that, i do have this site saved

    https://www.w3schools.com/html/html_examples.asp

    and found this

    https://www.w3schools.com/cssref/try...kground-color2

    I have looked at thinking the rows would be the filled section, something like:

    From this:

    Code:
        blankRow = "<tr style='height: 5px;'>" & _               "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "</tr>"
    To This

    Code:
        blankRow = "<tr style='height: 5px;'>" & _               "<td style='height: 100%;'>background-color: rgb(201, 76, 76)&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "</tr>"
    Which just adds to the empty row, i have now removed, just trying to find out how I would fill the empty cells, then i will find the RGB for grey for example

  14. #29
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Yey, got it, happy days

    Code:
        blankRow = "<tr style='height: 5px;'>" & _               
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "<td style='background-color:rgb(128,128,128)';'height: 100%;'>&nbsp;</td>" & _
                   "</tr>"
      '  blankRow = "<tr style='height: 5px;'>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "<td style='height: 100%;'>&nbsp;</td>" & _
                   "</tr>"

  15. #30
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    438
    you can replace AppendToBody() sub with this one:
    Code:
    Private Sub AppendToBody(ByVal strDay As String, ByRef strBody As String)
        Dim rs As DAO.Recordset
        Dim thisDriver As Variant
        Dim sql As String
        Dim sFH As String, sFHEnd As String
        Dim strBoxStart As String, strBoxEnd As String
        Dim strFS As String, strFE As String
        Dim sDayName As String
        Dim blankRow As String
        
        'blankRow = "<tr><td colspan='6'>&nbsp;</td></tr>"
        blankRow = "<tr style='height: 5px; background-color: rgb(220, 220, 220)'>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "<td style='height: 100%;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>&nbsp;</td>" & _
                   "</tr>"
        strFS = "<font size='3' face='Calibri' style='text-align=center'; vertical-align='middle'>" ' Mail Font
        strFE = "</font>" ' End Font’
        
        strBoxStart = "<script><table width='auto';style='text-align:left;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'><tr style='background:white;mso-highlight:blue' ctx.shadowblur;20; ctx.shadowcolor;blue></script>"
        strBoxEnd = "</tr></table>"
        
        sFH = "<font size='4' face='Calibri' style='text-align=center; vertical-align='middle'>"
        sFHEnd = "</font>"
        
        'strBody = strBody & sFH & "<B>" & strDay & "</B>" & sFHEnd & "<br>" & strBoxStart
        strBody = strBody & sFH & "<B>" & strDay & "</B>" & sFHEnd & "<br>"
        
        strBody = strBody & _
        "<table width='98%'>" & _
        "<tr>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>Day</th>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>Delivery Date</th>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>Driver</th>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>Delivery To (In Order)</th>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>Town</th>" & _
        "<th style='color: White; background-color: rgb(0,0,139);border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>PostCode</th><tr>"
        
        sql = "SELECT tblRoutes.DayName, tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo, tblRoutes.DelTo, tblRoutes.Town, tblRoutes.PostCode, tblRoutes.ETA " _
            & "From tblRoutes " _
            & "WHERE (((tblRoutes.DayName)= '" & strDay & "')) " _
            & "ORDER BY tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo;"
            
        With CurrentDb.OpenRecordset(sql, dbOpenSnapshot, dbReadOnly)
            If Not (.BOF And .EOF) Then
                .MoveFirst
                thisDriver = !driver
            End If
            Do While Not .EOF
                If IsNull(!DAYNAME) Then
                    sDayName = "No Date Planned"
                Else
                    sDayName = !DAYNAME
                End If
       
                strBody = strBody & "<tr>" & _
                    "<td style='background-color:#F5F5F5;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & sDayName & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & Format$(!DelDate, "dd-mmm-yyyy") & strFE & "</td>" & _
                    "<td style='background-color:#F5F5F5;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & !driver & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & !DelTo & strFE & "</td>" & _
                    "<td style='background-color:#F8F8FF;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & !Town & strFE & "</td>" & _
                    "<td style='background-color:#F5F5F5;border:1px solid black;font-family:calibri;border-collapse:collapse;padding:10px'>" & strFS & !PostCode & strFE & "</td></tr>"
           
                .MoveNext
                If Not .EOF Then
                    If !driver & "" <> thisDriver Then
                        thisDriver = !driver & ""
                        strBody = strBody & blankRow
                    End If
                End If
            Loop
            .Close
        End With
        'strBody = strBody & "</table>" & strBoxEnd & "<br>"
        strBody = strBody & "</table><br>"
            
    End Sub

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding Excel Cells To Email html body
    By DMT Dave in forum Access
    Replies: 15
    Last Post: 04-24-2022, 11:52 AM
  2. Replies: 1
    Last Post: 06-19-2018, 10:38 AM
  3. email body using html format
    By baronqueefington in forum Programming
    Replies: 5
    Last Post: 02-03-2015, 03:44 PM
  4. Sending Reports with email body having HTML
    By CeVaEs_64 in forum Access
    Replies: 28
    Last Post: 11-26-2014, 12:13 PM
  5. Export html to body of email issue
    By mmart33 in forum Reports
    Replies: 3
    Last Post: 02-28-2013, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums