RTF Control not displaying data

G

Guest

I'm sure it's something silly. I've installed the Lebans RTF control, placed
it on a form and set its control source to a field from a table. The control
is not displaying the data from the field. What am I missing?
 
S

Stephen Lebans

Do you currently have RTF formatted text in the Memo field? The RTF2 control
displays formatted/encoded RTF text....not plain text.
I have posted code in the past few months to add the required RTF encoding
to existing plain text fields.


From: Stephen Lebans - view profile
Date: Thurs, Mar 23 2006 12:38 am
Email: "Stephen Lebans"
<[email protected]>
Groups: comp.databases.ms-access, microsoft.public.access.forms
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


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/microsoft.public.access.forms/browse_fr...


From: Stephen Lebans - view profile
Date: Tues, Feb 14 2006 9:30 pm
Email: "Stephen Lebans"
<[email protected]>
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{\fonttbl{\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.
 
G

Guest

Stephen -
Thanks again for your response. Your link was very helpful.
I was wondering if you could answer a few more questions for me...

Is it safe to assume that the easiest way to deal with new records being
added by the user is to add code to prepend/append the rtf tags/params as the
record is being saved?

Is using/loading the RTF toolbar the only way to allow the user to change
formatting of certain characters within the memo field?

When reporting, should the RTF control and the memo field both be on the
report for the RTF control to work?

(Sorry if these questions are too basic but I very much appreciate the help)
 
G

Guest

One more question...how do I save the font/formatting changes within the
control using the shortcut menus? They're all responding as read-only.
(Please feel free to direct me to a resource. I don't want to keep bugging
you with little stuff. Although I've looked to find a resource, I may not
have found everything there is.)

I can't thank you enough!
 
S

Stephen Lebans

You do not need to do anything to new records only to exisitng records that
contain plain text.

The RTF2 control should be bound to your Memo field. You do not need to
include the Memo field on your report but you MUSt include the RTF2 control.

Your users can modify the contents of the RTF2 control via the standard
Access Toolbar I supplied or the RTF2 control's built in context sensitive
Popup Toolbar.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

Stephen Lebans

Any changes you make to the record are saved when you move off the record,
jsut as a normal TextBox control that is bound to a Memo field. What do you
mean it is responding as Read Only?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Here's what's going on...

First, the RTF2 control didn't show me highlighted text when I first added
the control. It wasn't until I restarted my project that I got highlighted
text. Besides that, if I right click on text I highlight then change the
formatting, it changes but as soon as the shortcut menu disappears I get an
error message with the red circle, white X saying the Property is Read Only.
Plus, you mentioned in the other response that I should be able to use the
standard Access toolbar or the built in Popup toolbar of the RTF2
control...neither one are available. The standard toolbar is disabled
completely when the RTF2 control is active and I don't have a popup toolbar.
I'm thinking either installation issues or maybe registration issues??? I've
obviously done something wrong...or haven't done enough.

To clarify, this is what I have done...I downloaded the control from your
website, extracted it, ran the setup on it, verified it was registered in
Access with a reference made in the code window. All was there. I put an
instance on my form, changed the control source to my memo field. I ran the
code you suggested in the previous post to update my plain text and the text
displays in the RTF2 control. My problems exist when I try to update
anything within the RTF2 control.

Hope this helps explain. And as always, thank for your help.
 
S

Stephen Lebans

Are you able to use the Form in the sample MDB you downloaded from the RTF2
Web page?

I said the standard Access Toolbar which refers to the sample Access Toolbar
located in the sample MDB. You would have to import this ToolBar into your
own MDB.

Check the RTF2 control's Property sheet to ensure you have not inadvertently
set one of the props that would cause the Read Only error.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Yes I was able to use the form in the sample mdb. My problem was that in my
efforts to get the control to work before I had updated my memo field with
the RTF formatting codes, I had inserted a line of code in the form_load
event that assigned the control source of the RTF2 control to my memo
field...on top of having the property already set. Once I deleted that line
of code, the control worked like a charm. I did import your toolbar and it
is functioning great as well.

I do have a few questions about how the control works...

Does the RTF2 control have to be bound? I have some static text in a report
that uses a lot of trademark superscript symbols as well as chemical symbols
that use subscript numbers. I'm currently using the trick of multiple label
controls grouped together. Didn't know if I could use the RTF control
instead (I tried with no luck, thought I might be missing something)

Is the memo field type the only field type the RTF2 Control supports?

Can you offer a suggestion on a workaround for ActiveX controls not being
able to be used in a continuous form? For example, I have a subform that
holds multiple article references for one particular product. Article titles
are typically italicized where the author names are not and it would be very
helpful to have the entire reference in one field. Unfortunately, merging
all related records into one memo field is not an option in this case.

Your control is very cool, btw. Thanks for helping me put closure on a year
long project.
 
S

Stephen Lebans

The control does not have to be bound.

Theoretically, you could use a standard Text field instead of a Memo field
but ou would be limited to 255 characters which would include all RTF
encoding. Your question does not make sense to me.

There is no workaround for not being able to use ActiveX controls on forms
in Continuous view.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top