Solved

RichTextBox

Posted on 1999-01-12
1
259 Views
Last Modified: 2013-12-25
I need to be able to have a richtextbox that contains text that needs to be filled with results from another form.  It is like a questionaire and I want the results displayed in the RichTextBox within an rtf I have already loaded.  For example the template has the text Company Name:  I want the text from the form that is already filled out to appear next to the Company Name: <text from other form>  I know how to get it from the other form what I don't know is how to format it in the rtf.

Thanks in advance!
0
Comment
Question by:kmdisney
1 Comment
 
LVL 3

Accepted Solution

by:
vbWhiz earned 20 total points
ID: 1489640
I have used the RichTextBox for creating form letters many times. The best solution I have come up with is like this:

Insert Certain Text into the letter in the richtextbox like '<<FirstName>>' then when placing the actual values into the letter use RichTextBox's built in search to replace '<<FirstName>>' with the actual value from the textbox.

To make life easier you could name each textbox from the form something intellegible like 'FirstName' or 'Address'. In the letter you would insert the names of the fields like this '<<FirstName>>' or '<<Address>>' to separate the fields from the rest of the text. Then you could use a routine like this to place the values into the RichTextBox - replacing the ugly '<<FirstName>>' type stuff.

SAMPLE CODE:

Public Sub InsertValues(TheSourceForm As Form)

Dim Ctrl As Control

For Each Ctrl In TheSourceForm.Controls

    If TypeOf Ctrl Is TextBox Then
        Do
            If Me.RichTextBox1.Find("<<" & Ctrl.Name & ">>") = -1 Then Exit Do
            Me.RichTextBox1.SelText = Ctrl.Text
        Loop
    End If
   
Next Ctrl

End Sub

To use this place a button on a form and on the click event insert some code like this:

RichTextForm.InsertValues Me


This will send the current form to the RichTextForm as a variable and allow the routine to cycle thru all the controls.

All you have to do now is create the other form. Name the fields and try it out!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vba find the last empty column 10 88
Problem to skip loop 6 54
Adding to a VBA? 6 59
Protecting vb6 & .Net code Obfuscation 18 93
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now