Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting data in HTML from memo field

Status
Not open for further replies.

lowtide

Programmer
May 17, 1999
24
0
0
US
I am trying to retrieve data from a memo field in an access db to format into an html page. My problem is I need to replace the end of line characters with &lt;BR&gt; tags. When I view the source code of the resultant html page the hard returns are there, so I know they are coming out of the db.<br>
I am more familiar with PHP than ASP and in PHP I simply do a replace &quot;\n&quot; with &quot;&lt;br&gt;&quot;. How is this done in ASP?<br>
<br>
Thanks
 
You're on the right track! You can use the replace function, but it doen't handle '\n'. The syntax would be:<br>
<br>
newstring = replace(memofield, chr(13)+chr(10), "&lt;BR&gt;")<br>
<br>
The chr(13)+chr(10) is the CR LF combination...you may not need the chr(10).<br>
<br>
Hope this helps.
 
That worked fine with the script I am using on an access database. But when I try to use it with a different script on a text field of a SQL 7 database I get the following error:<br>
<br>
Microsoft VBScript runtime error '800a005e' <br>
<br>
Invalid use of Null: 'replace' <br>
<br>
/update/events/edit.asp, line 183 <br>
<br>
Any ideas?<br>
<br>
Thanks,<br>
Lowtide
 
Looks like the memofield has no data. Try appending an empty string to the memofield<br>
<br>
By the way, you can use the constant vbcrlf instead of using the chr(13) + chr(10). Also, when concatenating strings, use & instead of +. <br>
<br>
so it would become<br>
<br>
replace(memofield & &quot;&quot;, vbcrlf, &quot;&lt;BR&gt;&quot;)<br>
<br>
<br>
-nick bulka
 
Nick,<br>
The problem wasn't in the replace function after all.<br>
I was doing an If memofield &gt; &quot;&quot; to verify if that field<br>
had any content, which is obviously wrong. After I fixed<br>
that part the original solution that noodle gave above<br>
worked fine.<br>
<br>
Thanks,<br>
Lowtide<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top