Link to home
Create AccountLog in
Avatar of get-ADuser -F ($_.Name -eq "Todd")
get-ADuser -F ($_.Name -eq "Todd")Flag for United States of America

asked on

Put HTML Border around Access VBA email script.

I need to put a border around one part of my VBA script for emailing a user.  I would like to know more about HTML and this answer I think will help me.  Right now I just want a border around the description part of my Access object "Description.  I would like the word Description inside the border as well with a carriage return.  I know I am close but all the searches come up with Excell VBA and cells.  Not Microsoft Access.  I copied what you see for the border just to see if I could put something to highlight the description.  That doesn't work either.  

Dim Msg As String


    Msg = "Workorder Information for      " & Me.FullName & ",<P>" & _

         "Priority is " & Me.Priority & "  With a due date of  " & Me.Due_Date & ".<P>" & _

         "Work Order Title: " & Me.Title & ",<P>" & _

         "Asset is " & Me.Asset & ",<P>" & _

         "Oxarc User is " & Me.FullCustomer & ",<P>" & _

          "Description: " & ",<P>" & _

         "<p style='border-left: solid 4px #FF6801;padding: 24px;margin-left:24px;'>" & Me.Description & "</p>"


 


Avatar of Norie
Norie

in the style change 'border-left' to 'border.
         "<p style='border: solid 4px #FF6801;padding: 24px;margin-left:24px;'>" & Me.Description & "</p>"

Open in new window

Avatar of get-ADuser -F ($_.Name -eq "Todd")

ASKER

I think I have it.  It works like I want.  But I would like to make the word, 'Description" Bold and the rest normal font.  I know thats not part of the question but it would help.  Here is where I am.  


 Msg = "Workorder Information for      " & Me.FullName & ",<P>" & _

         "Priority is " & Me.Priority & "  With a due date of  " & Me.Due_Date & ".<P>" & _

         "Work Order Title: " & Me.Title & ",<P>" & _

         "Asset is " & Me.Asset & ",<P>" & _

         "Oxarc User is " & Me.FullCustomer & ",<P>" & _

         "<table style='border-spacing: 2px; border-style: solid; border-color: #000000; border-width: 2px 2px 2px 2px;'>" & vbcrf & "Description: " & Me.Description & "</p>"



This should bold 'Description' and leave the actual text of the description in normal font.
         "<p style='border-spacing: 2px; border-style: solid; border-color: #000000; border-width: 2px 2px 2px 2px;'><strong>Description:</strong><br>" & Me.Description & "</p>"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer

I love it.  The border is just a little bit too thick  Workable, but if I can thin it out a bit, the solution is great.  Plus from these threads, I have learned a lot.  The code right now for a thick border is below.  A little thinner would be nice but if not available I can work with what I have.  


    Msg = "Workorder Information for      " & Me.FullName & ",<P>" & _

         "Priority is " & Me.Priority & "  With a due date of  " & Me.Due_Date & ".<P>" & _

         "Work Order Title: " & Me.Title & ",<P>" & _

         "Asset is " & Me.Asset & ",<P>" & _

         "Oxarc User is " & Me.FullCustomer & ",<P>" & _

         "<span>Workorder Information:</span><div style='border:solid'>    <p><b>Description: </b></p>    <p>" & Me.Description & "</p></div>"




SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.

That's It!!!   Wow I learned so much.  Thank you.  Thanks to everyone.  This is exactly what I needed. Here is the final cut. 


 Msg = "Assigned task for     " & Me.FullName & ",<P>" & _

          "Work Order Title Header : " & Me.Title & "<P>" & _

          "Expiditing this task is set to a " & Me.Priority & " Priority" & "  with a due date of  " & Me.Due_Date & ".<P>" & _

          "Working with Asset   " & Me.Asset & ",<P>" & _

          "Oxarc User requesting support is " & Me.FullCustomer & "<P>" & _

          "Work Order Reference Number is " & "ID# " & Me.ID & "<P>" & _

          "<span>Workorder Information: </span><div style='border:solid; border-width: 2px; '>    <p><b>Description: </b></p>    <p>" & Me.Description & "</p></div>"



If you are going to do this, might as well learn more about HTML tags and consistency.

If DIV and SPAN wok in one place, why not everywhere?  The <P> tag is a Paragraph tag and should also always need a closing </P>

I think what you are using it for is a line break.  That HTML tag is a <BR />

So putting it all together, I came up with:
Msg = "<div>Assigned task for     " & Me.FullName & ",</div>" & _
          "<div>Work Order Title Header : " & Me.Title & "</div>" & _
          "<div>Expiditing this task is set to a " & Me.Priority & " Priority" & "  with a due date of  " & Me.Due_Date & ".</div>" & _
          "<div>Working with Asset   " & Me.Asset & ",</div>" & _
          "<div>Oxarc User requesting support is " & Me.FullCustomer & "</div>" & _
          "<div>Work Order Reference Number is " & "ID# " & Me.ID & "</div>" & _
          "<div>Workorder Information: <div style='border:solid; border-width: 2px; '>    <p><b>Description: </b></p>    <p>" & Me.Description & "</p></div>"

Open in new window


I can't actually test that but hard-coding the Me.values I ended up with html of:
<div>Assigned task for : ME</div>
<div>Expiditing this task is set to a XXX Priority with a due date of 01/01/2001.</div>
<div>Working with Asset YYY,</div>
<div>Oxarc User requesting support is bill</div>
<div>Work Order Reference Number is ID# 12345</div>
<div>Workorder Information: <div style='border:solid; border-width: 2px; '>Description: <br/>Some desription</div>

Open in new window


Put that into an .html file and load it up in a browser I see:
User generated image
If you want the labels and values aligned, you can do padding and/or margins to control that with SPAN tags inside the DIV tags.
slightwv (䄆 Netminder) 

What you showed me is perfect, and exactly what I was trying to do.  Its formatted great.  I only knew about <P> from research and it seemed to do somewhat what I needed.  

So what is <Div>?  You mentioned <BR?>.  I must admit, I can read it better.


Also in this part of the code   "<div>Workorder Information: <div style='border:solid; border-width: 2px; '>    <p><b>Description: </b></p>    <p>" & Me.Description & "</p></div>" , how did it know to just put the border on the last line break?  I must tell you I learned more on this question than I have searching all over the place.  Cant wait to create more.  

The Internet can explain everything much better than I can.

>>So what is <Div>?
A Division:
https://www.w3schools.com/tags/tag_div.ASP

In a nutshell:  Each div separates itself on a page and starts on it's own 'line' in a page and ends on it's own line.

When playing with HTML and learning, I find creating local pages is probably the best.

Create a file, say C:\temp\ee.html and add the following:
<html>
Hello <div>I'm a div</div> World
</html>

Open in new window


Find it in Windows explorer and drag and drop it into a browser window to see the results.

>>You mentioned <BR?>

ALL html tags need an opening and closing tag.  Every <html> needs a closing </html> and so on...

So a BR is a line break:
https://www.w3schools.com/tags/tag_br.asp

So to put an empty tag on in a page would be <br></br>.

A shortcut is to open and close an empty tag can be done with:  <br /> with or without the space before the / but think the space is sort a of a standard but that is going from memory.

>> how did it know to just put the border on the last line break?

It put a border around the DIV.  Hope the DIV explanation above sort of helped explain it but if not, let me know and I'll try my best to explain it better.

>>I must tell you I learned more on this question than I have searching all over the place.

Happy to hear!!!  That is why most of us are here...   We like to not just provide answers but help others learn.  The Internet didn't exist back when some of us had to learn this and would have LOVED a resource like this site!

We ALL had to learn it at some point...

>> Cant wait to create more.  

We are here if you get stuck or have questions!

Wait until you pass straight HTML and get into CSS (Cascading Style Sheets)!!!  Then the real fun begins!!!

Not so much for emails but you did use a little CSS styles in there...  The border and width of the lines.  Remember the second S In CSS is Style and the style="" in the DIV tag.

There is a great site dedicated to CSS and shows off the real power of CSS:
https://csszengarden.com/

That site has the EXACT SAME content across ALL the submitted designs.  The ONLY thing that changes is the CSS that tells the browser how to display it.

Thank you so much.  Great explanations and very understandable.  Our company has registered with Jotforms and they encourage CSS and not HTML in the forms I will be creating.  So I'm going to do my best to make things much more professional.  I have time now that I have my official work order program for my technicians set up from access.  No more copy and paste.  That was not fun.  I followed you so I will be browsing things from your database category.  I like those too.  

No problems!

There are Experts here MUCH better than I am at HTML, CSS and overall Web stuff.   I hack my way through it most of the time and know enough to get myself into trouble....

I normally don't follow those areas of the site but hope to cross paths with you again sometime!