Solved

RichTextBox

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

12 Experts available now in Live!

Get 1:1 Help Now