Merge Fields

Mail Merge Data Article Word 97 Merge Article

 

The Word Field list contains a number of Word fields that can be inserted into your merge documents. The following descriptions are quoted directly from Microsoft Word 97 Help. For additional information, enter fields, inserting on the Index tab in Word Help, click on Display, and select the article Insert Word fields in a mail-merge document.

Customize documents created with mail merge.

You can include additional information in form letters and other merged documents by inserting the following Word fields in the main document. * ASK and FILLIN fields display a prompt as Word merges each data record with the main document.

  • ASK and FILLIN fields display a prompt as Word merges each data record with the main document. Your response is printed in the specific form letter, contract, or other merged document resulting from the data record.
  • IF (If...Then...Else...) fields print information only if a condition you've specified is met. For example, you can use an IF field to inform clients who live in a particular ZIP Code area that you are opening a nearby branch office.
  • SET (Set Bookmark) fields allow you to assign text, a number, or other information to a bookmark. You can use the information multiple times in the resulting merged documents. If the information changes, you can edit the SET field once rather than searching through the main document and changing each occurrence.

Examples of ASK and FILLIN fields

ASK and FILLIN fields display prompts so that you can add personal notes to clients or add other information that is not suitable to store in a data source. The prompt can be displayed each time a new data record is merged with the main document so that you can enter unique information for each resulting form letter or other merged document.

Insert a FILLIN field in the main document where you want to print your response to the prompt. An ASK field, on the other hand, uses a bookmark name to represent your response. To have Word print your response to an ASK field prompt, insert a bookmark field in the main document. You can insert the bookmark in multiple locations or use it in other fields, such as IF fields or = (Formula) fields. Insert the bookmark anywhere after the ASK field.

Example

This FILLIN field helps you fill in the correct information by displaying the patient name from the current data record; for example, "Please enter the appointment time for Patrick Martin." Insert an ASK or FILLIN field in the main document, and then insert the merge field in the field codes.

{ FILLIN "Please enter the appointment time for { MERGEFIELD PatientName }:"}

Example

The first ASK field includes the field switch \o, which is inserted if you select the Ask once check box in the Insert Word Field dialog box. The number you enter for CurrentRate is used in all of the resulting merged documents. The second prompt is displayed for each merged data record.

{ ASK CurrentRate "Enter the current lending rate:" \o }

{ ASK LoanRate "Enter the current loan rate for { MERGEFIELD ClientName }:" }

{ IF CurrentRate < LoanRate "You may want to consider refinancing your loan." " " }

Insert the ASK fields, and then insert the IF field in the main document. In the Insert Word Field dialog box, click a name in the Field name box as a temporary placeholder, and leave the Compare to box empty. In the IF field codes, replace the merge field with the CurrentRate bookmark. Type the name of the second bookmark between the quotation marks after the "<" symbol. If the second bookmark value contains only numbers, as in this example, delete the quotation marks.

Return to top

Examples of IF fields

IF fields perform one of two alternative actions, depending on a condition you specify. For example, the statement "If the weather is sunny, we'll go to the park; if not, we'll go to the movies" specifies a condition that must be met (sunny weather) for a certain action to take place (going to the park). If the condition is not met, an alternative action occurs (going to the movies).

The following IF field is a similar type of statement. If the current data record contains "San Francisco" in the City field, Word prints the first text in quotation marks in the merged document that results from that data record. Otherwise, Word prints the second set of text.

{ IF City = "San Francisco" "Please call our local office." "Please return the enclosed form in the provided envelope." }

Word inserts an IF field in this form when you click the Insert Word Field button on the Mail Merge toolbar and then click If…Then…Else. You can modify the IF field codes to perform the following tasks.

Compare a data field with another data field or bookmark
Insert other Word fields into an IF field
Perform calculations in an IF field
Require that more than one condition be met

Field codes: MergeRec field

{ MERGEREC }

Displays «MERGEREC» as a field result. Use this field in a mail merge main document to print the number of the corresponding merged data record in each resulting merged document.

Note: The number reflects the sequential order of the data records you've selected and possibly sorted for merging with the active main document. It does not indicate the actual order of the records as they occur in the "physical" data source. For example, a personnel database in Microsoft Access might contain thousands of records. However, to send a form letter to employees who've reached their five-year anniversary with your company, you'd select as your data source only the records of those five-year employees – a much smaller set of records. To print a "physical" record number, you must include a record number field in the data source and insert the corresponding merge field in the main document.

Example

The following example uses a MERGEREC field inside an = (Formula) field to create unique invoice numbers. When the main document is merged with the data source, the number resulting from the MERGEREC field is added to the numbers representing the date and time the invoices are printed.

Field:
Invoice Number: { = { PRINTDATE \@ "MMddyyHHmm" } + { MERGEREC } }

Result:
Invoice Number: 21390946

Return to top

Field codes: MergeSeq field

{ MERGESEQ }

Counts the number of data records that were successfully merged with the main document. Word starts numbering merged records from 1 each time you merge documents. The number may be different from the value inserted by the MERGEREC field.

For example, suppose that you merge only the range of records 10 through 25. The MERGESEQ number corresponding to the first data record merged is 1, even though the MERGEREC number for that data record is 10.

Field codes: Next field

{ NEXT }

Instructs Word to merge the next data record into the current resulting merged document, rather than starting a new merged document. The Next field produces no printed result. Word uses this field when you set up mailing label and envelope main documents by using the Mail Merge command (Tools menu). To list information from several data records in the same document, such as a membership directory or a price list, select the Catalog main document type in the Mail Merge Helper dialog box (Tools menu). The NEXT field is useful, however, to print a specific number of data records in one resulting merge document.

Insert a NEXT field after the first set of merge (MERGEFIELD) fields in the main document; otherwise, Word skips merging the first data record. Repeat the set of merge fields and the NEXT field in the main document only the number of times it takes to fill one page or to print the number of data records you want.

Note: NEXT fields cannot be used in footnotes, endnotes, annotations, headers, footers, or data sources. A NEXT field cannot be nested within any other field or used with the SKIPIF field.

Example

The following fields print three sets of names and phone numbers in each resulting merged document:

{ MERGEFIELD Name }
{ MERGEFIELD PhoneNumber }

{ NEXT }{ MERGEFIELD Name }
{ MERGEFIELD PhoneNumber }

{ NEXT }{ MERGEFIELD Name }
{ MERGEFIELD PhoneNumber }

Field codes: NextIf field

{ NEXTIF Expression1 Operator Expression2 }

Compares two expressions. If the comparison is true, Word merges the next data record into the current merge document. Merge fields that follow the NEXTIF field in the main document are replaced by values from the next data record rather than the current data record. If the comparison is false, Word merges the next data record into a new merge document.

Don't use the NEXTIF field in the current version of Word. You can select data records more easily by clicking the Query Options button in the Mail Merge Helper dialog box (Tools menu).

Notes

  • A MERGEFIELD field used as an expression field refers to data in the current data record, not the next data record.
  • NEXTIF fields cannot be used in footnotes, endnotes, annotations, headers, footers, or data sources. The NEXTIF field cannot be nested within any field.
Return to top

Field codes: SkipIf field

{ SKIPIF Expression1 Operator Expression2 }

Compares two expressions. If the comparison is true, SKIPIF cancels the current merge document, moves to the next data record in the data source, and starts a new merge document. If the comparison is false, Word continues the current merge document.

Don't use the SKIPIF field in the current version of Word. You can select data records more easily by clicking the Query Options button in the Mail Merge Helper dialog box (Tools menu).

Notes

  • A merge (MERGEFIELD) field used in an expression refers to data in the current data record, not in the next data record.
  • Don't use the SKIPIF field with the NEXT field.

Example

Inserted into a mail merge main document, the following field examines the contents of the Order field for the current data record. If the field contains a number less than 100, no merged document is produced for that data record:

{ SKIPIF { MERGEFIELD Order } < 100 }

Return to top

Mail Merge Data Article Word 97 Merge Article