Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Saving and displaying news articles in access


Message #1 by "Rod Murray" <rod-murray@c...> on Fri, 21 Mar 2003 17:13:02
I'm looking for a way to allow my client to type a news article in to a 
form text field. The part that i am having trouble with is when i'm 
trying to display this news article on the website.

I open the recordset and pull the article from the news table, but all 
formatting is lost! It is no longer in nicely organized paragraphs, but 
instead it is just one big text blob. How do i retain the formating with 
which the article was typed in to the form with?

Thanks...
Message #2 by "Josh Katsaros" <katsarosj@y...> on Fri, 21 Mar 2003 18:40:54
You have to put this in your code using a function to format your text.  
Look at the following example and modify it to your needs.

Place this above the <html> tag on your page so it is accessible to the 
entire page:

Function FormatStr(String)
  String = Replace(String, CHR(10) & CHR(10), "</P><P>")
  String = Replace(String, CHR(10), "<BR>")
  FormatStr = String
End Function

The first line replaces a double carriage return with a paragraph break, 
the 2nd line replaces a single carriage return with a break rule.

For the field that you want to format, the code will look something like 
the following:

<%= FormatStr(rs("Field1")) %>

You should also note that you can't use the Replace function on a NULL 
field, it will return an error.   You should check for NULL before you 
write the field, using an "If" statement, for example.

Hope this helps.

JK



> I'm looking for a way to allow my client to type a news article in to a 
f> orm text field. The part that i am having trouble with is when i'm 
t> rying to display this news article on the website.

> I open the recordset and pull the article from the news table, but all 
f> ormatting is lost! It is no longer in nicely organized paragraphs, but 
i> nstead it is just one big text blob. How do i retain the formating with 
w> hich the article was typed in to the form with?

> Thanks...
Message #3 by "Josh Katsaros" <katsarosj@y...> on Fri, 21 Mar 2003 18:51:26
Sorry,

After re-reading what I posted, I realized I told you the wrong thing.  chr
(10) is actually a line feed, chr(13) is a carriage return.  The code I 
gave you should give you the result you wanted though.

JK

> I'm looking for a way to allow my client to type a news article in to a 
f> orm text field. The part that i am having trouble with is when i'm 
t> rying to display this news article on the website.

> I open the recordset and pull the article from the news table, but all 
f> ormatting is lost! It is no longer in nicely organized paragraphs, but 
i> nstead it is just one big text blob. How do i retain the formating with 
w> hich the article was typed in to the form with?

> Thanks...

  Return to Index