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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Displaying Value of a Field

Status
Not open for further replies.

dbinfoweb

Technical User
Nov 20, 2001
59
US
Hello, Hope someone can help. I have a Access db and a column containing a lengthy value (something like a couple of short paragraphs). I would like to display it on a ASP page but it displays the paragraphs in one big block continuously without a break in paragraph like the original format. I want to display it into two paragraphs or more (like the original). I am wondering how I can achieve that. Thanks for any help in advance.
 
You can use the replace function to replace the linebreaks (which are ignored by the browser) with
Code:
<br>
tags (which are not ignored by the browser)

-Tarwn ________________________________________________________________________________
Sometimes it is how you ask the question: faq333-2924
Many ASP questions have already been answered, please check faq333-3048 and use the search tool before posting
 
Tarwn is right, you can do this as follows...
Code:
strText = Replace(objRecordset(&quot;YourTextField&quot;),vbcrlf,&quot;<BR>&quot;)
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Thanks for your help, Tarwn and Tony,

This is the error I got when I used the Replace function:

&quot;ADODB.Recordset error,
Item cannot be found in the collection corresponding to the requested name or ordinal. &quot;

The strText is actually a sql statement like so...

sqlString = Replace(oRS(&quot;Select comment FROM sales;&quot;),vbcrlf,&quot;<BR>&quot;)

Do I miss something?

Thanks.
 
you cannot replace a query directly

first set the recordset

query2 = &quot;Select comment FROM sales&quot;
Set con = Server.createObject(&quot;ADODB.Connection&quot;)
rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

Set rs = con.Execute(query2)
Do while not rs.EOF
somevar = rs(&quot;comment&quot;)

somevar = Replace(somevar,vbcrlf,&quot;<br>&quot;)
rs.MoveNext
Loop
 
Or you could wrap the output of the value in <pre> tags to preserve the original formatting (this should also catch tabs, etc. where as the Replace method will only catch line breaks)
 
Oh, wow! It works! This is great! Thanks for everyone who replied and provided some enlightenments here. I really learnt a lot from this forum. You all did an awesome job! Thanks for all your help again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top