The RTF control can only display RTF encoded text. If you want to simply
display plain text then wrap your plain text within the required RTF
encoding.
Here's a previous post of mine on a related issue.
http://groups.google.ca/group/micros...46dace11b9fd7e
From: Stephen Lebans - view profile
Date: Tues, Feb 14 2006 9:30 pm
Email: "Stephen Lebans"
<ForEmailGotoMy .WebSite.-WWWdotlebansdot ...@linvalid.co m>
Groups: microsoft.publi c.access.forms
Not yet ratedRating:
show options
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse | Find messages by this author
Let me know how you make out.
Make sure your Form has:
A TextBox control named txtComment bound to the Comment field(just o you can
see the RTF encoding)
an RTF2 control bound to the Comment field
A CommandButton named cmdRTF
In your References, make sure the ref to DAO is higher in the list than ADO.
Place this code behind the Command Button.
Private Sub CmdRTF_Click()
On Error GoTo Err_CmdRTF_Clic k
Dim sRTFdata As String
Dim sHeader As String
Dim sText As String
sHeader =
"{\rtf1\ansi\an sicpg1252\deff0 \deflang1033{\f onttbl{\f0\fnil \fcharset0
Arial;}}"
sHeader = sHeader & "{\colortbl
;\red0\green0\b lue0;}\viewkind 4\uc1\pard\cf1\ fs24"
' I could have shortened the code but I wanted you(and others I refer to
this posting) to see what is happening at every step.
With Me.RecordsetClo ne
' Move to first record
.MoveFirst
' Loop until all records are processed
' This example uses a field named "Comment"
' Note this is the name of the FIELD not the
' name of the TextBox control bound to this field
Do While Not .EOF
.Edit
sText = IIf(IsNull(.Fie lds("Comment")) , "", .Fields("Commen t"))
' See if field is empty
If Len(sText & vbNullString) = 0 Then
sRTFdata = sHeader & "}"
Else
sRTFdata = sHeader & sText & "\par }"
End If
' Save our RTF encoded string back to Comment field
.Fields("Commen t") = sRTFdata
.Update
' Move to next record
.MoveNext
Loop
End With
Exit_CmdRTF_Cli ck:
Exit Sub
Err_CmdRTF_Clic k:
MsgBox Err.Description
Resume Exit_CmdRTF_Cli ck
End Sub
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
<si***@intology .com.au> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
I have an unbound RTF2 control in an Access 2003 form which I set to
show either unformatted text or else text with words and sentences
highlighted. I do this by setting the PlainText property, getting back
the rtfText and then adding the highlighting strings and resetting
rtfText as below:
sqry = "Select * from TextContent where FileID = " & ID
Set rs = CurrentDb().Ope nRecordset(sqry , dbOpenSnapshot)
With rtfUnformatted
.rtfText = ""
If Form_QMeta.chkL ineBreak Then
sText = rs!TextContent
Else
sText = cleanup_html(rs !TextContent)
End If
.PlainText = sText
If Not chkHighlight Then Exit Sub
sRTF = .rtfText
....
After making some other changes to the form I find I get the message
"Property is Read-Only" when trying to set the .PlainText value. I've
tried adding the control again, changing only the font size and back
colour, but cannot see what I might have done to prevent me from
setting this property.
Any help appreciated.
Simon Kravis