Field codes: MergeRec field

In a merged document, the MergeRec field displays the ordinal position of the current data record (data record: A complete set of related information that corresponds to one row of information in the data source. All information about one client in a client mailing list is an example of a data record.). The number reflects any sorting or filtering that you applied to the data source (data source: A file that contains the information to be merged into a document. For example, the list of names and addresses you want to use in a mail merge. You must connect to the data source before you can use the information in it.) before the merge. You can use the MergeRec field to number each merged document in a mail merge, in the order that you sorted the data source.

For example, if a personnel database contains 2,000 records, the values of the MergeRec fields would range from 1 to 2,000. However, to send a form letter to employees who reached their five-year anniversary with your company, you would filter the data source, yielding a much smaller set of records, such as 500.

If you used the entire database in the merge, the MergeRec value in a particular employee's letter could be 1,000. With the filter in effect, however, that same employee's MergeRec value would not exceed 500.

The value of the MergeRec field for a data record is also affected by the sort order of the data source. For example, if you sort your mailing list alphabetically in ascending order, a name that begins with A has a low MergeRec number. However, if you sort the same list alphabetically in descending order, the same name has a higher MergeRec number.

Syntax

When you view the MergeRec field in your document, the syntax looks like this:

{ MERGEREC }

 Note    A field code tells the field what to show. Field results are what’s shown in the document after having evaluated the field code. To toggle between viewing the field code and the field code results, press Alt+F9.

Instructions

You can use the MergeRec field in a document or as part of a mail merge.

To use the MergeRec field in a document, do the following:

  1. On the Insert tab, in the Text group, click Quick Parts, and then click Field.
  2. In the Field names list, select MergeRec.
  3. Click OK.

To use the MERGEREC field as part of a mail merge, while you are setting up the mail merge, do the following:

  • On the Mailings tab, in the Write & Insert Fields group, click Rules, and then click Merge Record #.

Example

The following example uses a MergeRec field next to a Printdate field to create unique invoice numbers. When the main document is merged with the data source, the number that results from the MergeRec field is appended to the numbers that represent the date and time that the invoices are printed.

Invoice Number: { PRINTDATE \@ "MMddyyyyHHmm" } { MERGEREC }

For the twelfth invoice, printed at 9:46 on Feb. 13, 2007, the document looks like this:

Invoice Number: 02132007094612

 
 
Applies to:
Word 2013, Word 2010, Word 2007