473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Error Setting PlainText value for RTF2 control

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().OpenRecordset(sqry, dbOpenSnapshot)
With rtfUnformatted
..rtfText = ""
If Form_QMeta.chkLineBreak 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

Mar 22 '06 #1
1 3854
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.com>
Groups: microsoft.public.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_Click
Dim sRTFdata As String
Dim sHeader As String
Dim sText As String
sHeader =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttb l{\f0\fnil\fcharset0
Arial;}}"
sHeader = sHeader & "{\colortbl
;\red0\green0\blue0;}\viewkind4\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.RecordsetClone
' 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(.Fields("Comment")), "", .Fields("Comment"))
' 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("Comment") = sRTFdata
.Update
' Move to next record
.MoveNext
Loop
End With
Exit_CmdRTF_Click:
Exit Sub
Err_CmdRTF_Click:
MsgBox Err.Description
Resume Exit_CmdRTF_Click
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*********************@g10g2000cwb.googlegro ups.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().OpenRecordset(sqry, dbOpenSnapshot)
With rtfUnformatted
.rtfText = ""
If Form_QMeta.chkLineBreak 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

Mar 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bruce Rusk | last post by:
I've just started using Stephen Lebans' RTF2 control in a database, linked to a Memo field, and am finding it extremely useful (incidentally, in ACC2002 I'm using the class and withevents rather...
4
by: Marion Neubauer | last post by:
Hi! I'm using the RTF2 Control from Lebans web site with MS Access 2000. It's working very good. Now i want to create a letter with the formated text of the RTF2 control in MS Word 2000, but it...
6
by: Sharper | last post by:
I have just downloaded lebans rtf2 which initially looks very interesting. Having a little trouble though in getting the RTF2 toolbar to appear on my own db although it is on the sample. I have...
11
by: D Perron | last post by:
I am using the RTF2 activeX control from Stephen Leban's website and it works really well when there is one memo field. However, I cannot get it to work with multiple memo fields (I have 4). I...
2
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
1
by: Jako | last post by:
Hi guys... Well once again I'm in a dilemma. Currently I have a RTF2 object in Access that is linked to a memo field in a table, the reason for this is so that I can have bullets and numbers in...
4
by: Tom | last post by:
Is it possible to encrypt a value in the my.settings area in VB.NET 2005? I.E. Can I add a settings value (via My Project / Settings) and have it encrypt that value so that if anyone looks at the...
1
by: Bob Alston | last post by:
Lebans RTF2 Active X control - How to load contents from DOC or RTF file at run time???? Bob
0
by: lalob | last post by:
Hi, in an Access 2003 Application I'm using S. Leban's RTF2-Control. The data are stored in a linked Oracle-Table (varchar2(4000)). If text is used everything is working well. Now on user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.