Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Rich Text Box in VB6

Status
Not open for further replies.

londonmay

Programmer
Dec 12, 2007
3
I am trying to build a very simple email function into a program. I have a simple form which has a Rich Text Box. The contents of this is stored in a memo field in an Access database.

When recalling the message and displaying it's detail I cannot seem to get the memo field contents to display in the Rich Text Box unless it is actually bound to the field via a data control.

Surely I don't have to have it bound in order to display these contents?

Any suggestions would be most appreciated.
 
Do the contents show when assigned to a variable?

Dim strMemo as string
strMemo = rs.fields("MyMemo").Value
Debug.? strMemo

If so, show us how you are assigning the RichTextBox to the value in the memo field.

If not, and there is really text in the memo field, start with some short text (nothing big) in the memo field and see if that works.
 
Rich text boxes have .text and .textrtf and .seltext
The first one contains only the wording of simple ascii text while the second contains all the code for colors and text sizes.
If you try to put simple text into the .textrtf you dont get anything. You have to supply the whole code stuff.
The only way to add text with formatting & colors etc is to use .seltext after making .text="" otherwise the text is added to the end of what is already there. Setting .selfont & .selbold etc BEFORE adding text, sets the font and bold etc.
Be sure you are looking at and using the right one.
Your database field has stored all the .textrtf code and that is the reason it works.
 


Yes, that sounds like what they have done, used TextRtf with plain text
 
Thanks everyone for the replies. I am aware of the different .text and .textrtf properties. When saving the contents of the box I use the .textrtf property (assuming that this is the way to save all the formatting details)

rs.fields("Message") = rtbMessage.textrtf

Similarly when trying to display the memo field text I am using the same property. Is this what I am doing wrong?

I am not trying to put plain text into the .textrtf property.

I am aware of the .seltext property but thought that was associated with selecting text and would not apply as there is nothing in the box to start with?

At this stage, I'm not even interested in formatting of any kind, just want to get the text in there, first, then worry about that stuff later.
 
You say you want to get "the text in there"
What text is "the text" if it is not already what you have in your database?

Are you trying to manually enter text in a rich text box? If so you have to first make sure the cursor is at the start of the box by richtextbox.text="" with a clear field button or something, or selecting the box with the mouse and pressing delete.

If you are trying to enter text from code, richtext.text="Hello"

Why wouldn't you want it bound to the database?
If you don't have it bound to the database you will never store what you have entered once you move to another database record.
 
How large is the data in the memo field? (therefore my previous questions)
 
Sorry for the confusion. It's only a very simple function which does the following:

1. User writes an email, fills out the various to, from, subject etc details
2. Message "text" is written in a multi-line rich text box
3. User sends message, message details written to Access db. Details written via rs.fields("Message") = rtbMessage.textrtf

Later user may wish to recall (view) original email. All message details are dispalyed (to, from, subject etc) in relevant text boxes with the message "text" component to be shown in the rich text box.

At present I am simply doing rtbMessage.textrtf = rs.fields("Message").

The data is small ("hello how are you?") and yes it shows in a variable.

Why am I not binding? No particular reason as such, I just never have.

Thanks.

 
I did the same thing in one application and it worked for me.
I used an Access2000 database memo field.
Are you sure the correct record is current before sending the text to the control and the richtextbox is not disabled or locked, multiline set to true.
Also first set the rtbMessage.Backcolor = a different color to the text color otherwise you wont see the text!
eg. rtbMessage.Backcolor=&H808080
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top