Recently, a new Text Control Reporting user asked the following question in our technical support:

Can a Word template be merged with a DatSet with multiple tables that have columns with the same name?

The answer is: Absolutely yes!

Data relations between tables are used automatically by Text Control Reporting. A master table is specified when calling the Merge method. All relations between child tables and the master table is defined as a prefix in the merge field name concatenated with a dot:


Our sample database has the following structure:

Prefixed merge field names: Using related tables

The master table is Sales_SalesOrderHeader. The child table Sales_SalesOrderDetail has the child tables Production_Product and Customer_Customer.

A merge field from the master table doesn't need a prefix. AccountNumber is coming directly from the master table Sales_SalesOrderHeader. Merge fields that should be populated with values from related tables are getting a prefix that consists of the relation path concatenated with a dot where the master table is omitted.

The following illustration shows the merge fields on the left side and their relations on the right:

Prefixed merge field names: Using related tables

Notation in Merge Blocks: Access to Nested DataTables

The master table is the base table for the complete report. Inside of merge blocks, the master table for this block is the merge block table. All child tables of this block table can be used inside of the merge block with the same notation. Consider the following merge block:

Prefixed merge field names: Using related tables

The block is named Production_Product. All columns of this base table are used without any prefix. Columns of nested tables can be accessed with the prefix such as Production_ProductProductPhoto.ProductPhotoID which is a related child table of Production_Product.

This concept allows you to iterate over any data, in any way, across any part of the template with different DataTables in various merge blocks.