pcalabria
asked on
How to I read text a text box using code in another form?
I have a text box which has several lines of text. Each line was created using code and the vbcrlf character.
Example:
strMyExample="Line Number One" & vbcrlf & "line Number two" & vbcrlf & "line Number three" & vbcrlf
Forms!frmAutoQuote.MyExamp le=strMyEx ample
Now, from code in another module, I want to create an HTML email using the text in the textbox.
I use the code strMyText="<table><tr><td> " & Forms!frmAutoQuote.MyExamp le & "</td></tr></table>
When I use the text to print in the email all the carriage returns are lost, and the code prints as if it paragraph form.
Example:
strMyExample="Line Number One" & vbcrlf & "line Number two" & vbcrlf & "line Number three" & vbcrlf
Forms!frmAutoQuote.MyExamp
Now, from code in another module, I want to create an HTML email using the text in the textbox.
I use the code strMyText="<table><tr><td>
When I use the text to print in the email all the carriage returns are lost, and the code prints as if it paragraph form.
HTML does not recognise white space formatting unless inside <pre> tags.
If you want line breaks you muse use the <br/> tag in addition to (or instead of) the carriage return. The latter will be ignored if it is present. The reason for including it would be if you want to view the generated source after the fact - it makes for easier to read formatting - in HTML view though the CR is not rendered.
If you want line breaks you muse use the <br/> tag in addition to (or instead of) the carriage return. The latter will be ignored if it is present. The reason for including it would be if you want to view the generated source after the fact - it makes for easier to read formatting - in HTML view though the CR is not rendered.
ASKER
Still Stuck
@Anders The HtmlEncode encode function does not seem to work. Perhaps because I'm using Access 2k?
@Julian I didn't understand your message. To create the text in my text box I am not using HTML. Line breaks were generated, as per my example, using vbCRLF. Now I want the text to appear in an HTML email. I suspect the problem is that the HTML email is ignoring the vbCRLF which is probably chr(10) & chr(13)... Are you suggesting I write text to the textbox using vbcrlf & "<br/> at the end of each line?" ????? I'll give that a try but then where doe the <pre> go?
@Anders The HtmlEncode encode function does not seem to work. Perhaps because I'm using Access 2k?
@Julian I didn't understand your message. To create the text in my text box I am not using HTML. Line breaks were generated, as per my example, using vbCRLF. Now I want the text to appear in an HTML email. I suspect the problem is that the HTML email is ignoring the vbCRLF which is probably chr(10) & chr(13)... Are you suggesting I write text to the textbox using vbcrlf & "<br/> at the end of each line?" ????? I'll give that a try but then where doe the <pre> go?
I suspect the problem is that the HTML email is ignoring the vbCRLFPlease read my post again
CR are not rendered in HTML - you need to use the <br/> tag.
I'll give that a try but then where doe the <pre> go?
The <pre> does not go anywhere - I was trying to explain that the only time CR chars are rendered is if they are inside <pre> tags (pre formatted tags) otherwise HTML ignores them.
For your purposes all you need is <br/>
The CRLF is optional - it won't hurt to put it in but it won't be rendered.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to both of you for helping.
Hielo's solution was exactly what I needed and worked perfectly.
Hielo's solution was exactly what I needed and worked perfectly.
Yes, HTMLEncode is 2007+. But I see you got it working :)
ASKER
@Anders - Yes, and thank you. We have started migrating to A2016, I'm sure this will someday help!
Open in new window
To play around, and get an idea of what it does, you can use:
Open in new window