Results 1 to 10 of 10
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Adding a Seperator in HTML Table

    Hi Guy's, I have 5 HTML table setup for Monday to Friday, all works a dream but unsure if or how i can add a separator

    separator being a blank row in the HTML table ? the code below will add schedules for all "drivers" for that particular day of week, can or how can I add a blank row after each driver ?

    The below is all drivers schedules for Friday

    Code:
    strHTML5 = "<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>Del No</th><th>Delivery To</th><th>Town</th><th>PostCode</th><th>Qty</th><th>ETA</th><tr>"
            
        strBody5 = strHTML5
    
    
        strSQL5 = "SELECT tblRoutes.DayName, tblRoutes.DelDate, tblRoutes.Driver, tblRoutes.DelNo, tblRoutes.DelTo, tblRoutes.Town, tblRoutes.PostCode, tblRoutes.Qty, tblRoutes.ETA " _
                & "From tblRoutes " _
                & "GROUP BY tblRoutes.DelDate, tblRoutes.DayName, tblRoutes.Driver, tblRoutes.DelNo, tblRoutes.DelTo, tblRoutes.Town, tblRoutes.PostCode, tblRoutes.Qty, tblRoutes.ETA " _
                & "HAVING (((tblRoutes.DayName) = ""Friday"")) " _
                & "ORDER BY tblRoutes.Driver, tblRoutes.DelDate, tblRoutes.DelNo;"
    
    
        Set rs5 = CurrentDb.OpenRecordset(strSQL5)
        
        Do While Not rs5.EOF
        
        If IsNull(rs5.Fields("DayName")) Then
            sDayName = "No Date Set"
        Else
            sDayName = rs5.Fields("DayName")
        End If
        
        strBody5 = strBody5 & "<tr>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & sDayName & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & Format(rs4.Fields("DelDate"), "dd-mmm-yyyy") & strFE & "</td>" & _
            "<td style='background-color:#F5F5F5'>" & strFS & rs4.Fields("Driver") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs4.Fields("DelNo") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs4.Fields("DelTo") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs4.Fields("Town") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs4.Fields("PostCode") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs.Fields("Qty") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs.Fields("ETA") & strFE & "</td></tr>" & "|"
            
        rs5.MoveNext
        Loop
    Hope i have asked this clearly



    After each driver (Add a blank row to sperate)

    Or a suggested method to make separation ?

    Thank you indeed

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    usual way would be to use the paragraph code

    <P>......</P>

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Thanks CJ, wouldn't <br> tag do it also ?

    I am thinking this where I have changed highlighted red

    Code:
    If IsNull(rs2.Fields("Driver")) Then
            strDriver = ""
        Else
            strDriver = rs2.Fields("Driver") & "<br><P></P></br>"
        End If
    But then i guess i am generating line feed and paragraph

    Not tried yet but is the way i am trying correct ?

    Code:
        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 & strDriver & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("DelNo") & 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:#F8F8FF'>" & strFS & rs2.Fields("PostCode") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("Qty") & strFE & "</td>" & _
            "<td style='background-color:#F8F8FF'>" & strFS & rs2.Fields("ETA") & strFE & "</td></tr>" & "|"

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    I'm not an html expert but pretty sure that won't do what you want. There is a difference between line breaks and new paragraph - but guess it might work if you included it twice. You may find this link useful

    https://www.w3schools.com/TAGs/

  5. #5
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    167
    "after each driver"... so you want to either (a) insert a blank row or (b) use CSS to make the "header" row taller? (If the latter, use <th><td>...</td></th> and then format the <th> with CSS. W3Schools is your friend.

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi Guy's thank you

    @madpiet

    Yes exactly that, add a blank row between each driver,

    (a) insert a blank row


  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Just unsure how,

    didn't know if i can set a varibale prior to table then include it in the body or do i need a "for each" prior to body or do something within the body on the rs.fields driver (strDriver)

  8. #8
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    167
    <tr>
    <td></td>
    <td></td>
    ...
    </tr>

    I'd create a string for a blank row... like the above (I added returns to make it clearer). You could use the recordset and get rs.fields.Count and loop to create the blank row... then assign that to a variable. Then append that after the driver.

  9. #9
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    167
    Create variables at the top of your code, then use them wherever you want to inside your function/sub.
    (I'd use styles/classes to do the formatting. LOTS more flexible. Inline formatting is a pain if you want flexible code/styles.)

  10. #10
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    167
    Oh, the "after each driver" bit... you want to store the "old" value for the driver's name in a variable, and then compare to the new value (rs2.Fields("Driver")) and when the two are not the same, then you insert a blank row (just create it as a string)...

    Const cBLANKROW As String = "<tr><td></td><td></td></tr>"

    then in your code, when you detect the change, you'd just append the cBLANKROW value to your table in a variable

    strTable = strTable & cBLANKROW

    and then you'd continue your loop, reading the next record.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding Signature After HTML Table
    By DMT Dave in forum Access
    Replies: 6
    Last Post: 12-03-2022, 03:12 PM
  2. Adding Excel Cells To Email html body
    By DMT Dave in forum Access
    Replies: 15
    Last Post: 04-24-2022, 11:52 AM
  3. Adding Items To HTML Email Body
    By DMT Dave in forum Access
    Replies: 6
    Last Post: 01-03-2022, 04:15 AM
  4. Replies: 16
    Last Post: 08-15-2014, 12:03 PM
  5. Decimal seperator between different languages
    By seshan in forum Programming
    Replies: 3
    Last Post: 01-31-2010, 03:03 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