Solved

RichTextBox

Posted on 1999-01-12
1
261 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 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