Mail Merge
Mail merge inserts the contents of database fields at specified positions of a previously prepared document, the template. With TX Text Control ActiveX, these positions are Marked Text Fields, and a Visual Basic sample program in three parts shows how to fill them from a database, print the merged documents and let users build templates of their own.
Storing a whole document in a database is a different task: Connecting to Databases shows how to save the entire contents of a TXTextControl in one database field.
How the Sample Program Is Organized
Each part of the sample extends the previous one, and each has its own project in the Samples\vb6\MailMerge directory:
- Merging Database Data and Text loads a template, browses the records of a database and merges the current record into the Marked Text Fields of the template.
- Printing More Than One Record adds a print queue and prints the queued records with a hidden
TXTextControl. - Dynamic Template Generation lets the user select a database and insert its fields into the template, and saves the database name with the template.
Find the Right Page
| If you want to | Read |
|---|---|
| Fill the fields of a template with a database record | Merging Database Data and Text |
| Print several records in the background | Printing More Than One Record |
| Let users insert database fields into a template | Dynamic Template Generation |
| Store a complete document in a database field | Connecting to Databases |
| Learn how Marked Text Fields work | Marked Text Fields |
Pages in This Section
- Merging Database Data and Text: find template fields by name and fill them with the data of a record.
- Printing More Than One Record: queue records and print each merged document.
- Dynamic Template Generation: build a layout editor for templates of any database.
- Connecting to Databases: save and retrieve documents as RTF in a database field.