Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Table of Contents

Merge Fields

Excerpt

A WordWriter template is a Microsoft Word file that contains merge fields. A merge field displays a data source field (for example, a database column name). A merge field is created in Microsoft Word and bound in code to a data source. The data source may be an array, a DataSet, a DataTable, or a DataReader. When you run the code, WordWriter populates the merge fields with data source values.

A template may contain multiple sets of merge fields. Each set of fields binds to a single data source. Implicitly or explicitly, a merge field always specifies both a data source and a column. For example, in the merge field*«Products.ProductID», "Products" is the data source and "ProductID" is the column. The merge field«ProductID»* refers to the "ProductId" column from the first data source defined in the WordWriter code.

...

Info

The Main Document and Repeat Blocks
A repeat block is a text fragment, a list, or a table row - defined by a Word bookmark - that contains merge fields and that will be repeated for each row returned from the database. The main document is any part of the template that is not within a repeat block. You can assign one data source to each repeat block, and multiple data sources to the main document. Only one row of data can be imported to each set on main document merge fields.

Merge Field Names
Anchor
names
names

...

Info

Use brackets if your column name does not conform to these rules
The exception of these rules is when a column name is enclosed in brackets (for example, «Products.[Product Category]» . To include spaces or unicode characters in the data source column name, use this format:«DataSource.[Column Name]»
For example: «Employees.[Street Address]» . The [Column Name] format allows you to match any SQL column name exactly. Legal characters within the brackets include every character except parentheses () or brackets [].
When creating these fields with WordApplication or editing the field codes manually, the merge field name must be enclosed in quotes. For example, it should be { MERGEFIELD "[data source].[column name]" }. Any modifiers must also go in the quotes, but the formatting options must go after the quotes.

...