Remove HTML and RTF Tags from String

GohDiamond

"Access- Imagineer that!"
Local time
Today, 17:16
Joined
Nov 1, 2006
Messages
550
Hiya, I'm using Access 2010.

I'm trying to do something stupid so I'm getting stupid results, naturally. But I thought I'd run this by youz guyz and see what you think.

I'm trying to append some text to a field used for comments for a Team Member profile. I don't really want to create a comments table for multiple comments regarding changes to the profile.

Some comments already exist and I want to add some more information programmatically when the profile is updated using a batch update at the end of a reporting period.

I thought it'd be easy in a query,

New Comment:[EXISTING COMMENT] & "; Additional Comment"

But I was getting HTML Tags when I tried to concatenate the strings. "<div><font color=black> EXISTING COMMENT HERE </font></div>" then a linefeed and <div> </div>; Additional Comment HERE.

I found a function to kill all the html tags but the visual linefeed and the " " tag won't go away.

I'd like to concatenate two pure text strings to get one pure text string to put back into the comments field which will just be text wrapped with no forced linefeeds. Can anyone point me in the right direction?

Cheers Goh!
 
Last edited:
Use Replace function ?
Code:
Replace(theString, vbCrLf, vbNullString)
Replace(theString, " ", vbNullString)
Or simply use PlainText() method
Code:
? PlainText("<HTML><BODY><p>Hello World !!</P></BODY></HTML>")
Hello World !!
 
You should fix the underlying problem rather than use band-aid. If you set the textbox text format to Plain text i stead of Rich text, and likewise in the field, then your HTML tags will be gone.
 
Thanks to both pr2-eugin and spikepl,

The final solution in the query ended up as follows:

Apn_Emp_Comment: PlainText(KillHTML([Emp_Comment],"") & "; Additional Comments Here")

Results look like: Per Ken 11/6 - LOFF - becomes OPEN; Additional Comments Here

The Function KillHTML() I found on the net:http://www.tech-archive.net/Archive/Access/microsoft.public.access.queries/2004-08/0776.html

And I agree that the field should be plaintext, but some others want to be able to use RTF in that field, thus the workaround.

... and Thanks for all the fish!
Cheers,
Goh
 

Users who are viewing this thread

Back
Top Bottom