
Tips.Net > WordTips Home > Printing > Mail Merge > Conditional Processing During a Mail Merge
Summary: Using the mail merge feature of Word, you can combine data and boilerplate text in powerful ways to create just the documents you want. You aren’t limited to placing data in a merge document; you can also conditionally control the way in which data is merged. This tip explains how. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
When using Word's mail merge feature, you are not limited to using only the actual data fields when putting together your merge document. Word also includes special fields that allow you to conditionally control how Word does the merging. These types of fields can be easily inserted by clicking on the Insert Word Field drop-down list on the Mail Merge toolbar. The three fields you can use for conditional processing are as follows:
You should note that you cannot use Word's conditional mail-merge fields to compare values in any record other than the current one. It would be very nice to compare the contents of a data field in the current record with the contents of the same data field in the previous record, but Word will unfortunately not allow it.
One possible workaround to this shortcoming--if you are using an Excel worksheet as your data source--is to simply copy the controlling field (column) to another column, and then offset it by one row. Here is an example:
| Item | Category | OldCat | ||
|---|---|---|---|---|
| Dogs | 1 | |||
| Cats | 1 | 1 | ||
| Birds | 2 | 1 | ||
| Pigs | 3 | 2 |
As Word processes each record of the data source, the value of the OldCat data field is the same as the contents of the Category data field in the previous record. Thus, you could use a compound field such as the following to check and act upon the comparison between the fields:
{IF {MERGEFIELD Category} <> {MERGEFIELD OldCat} "first text" "second text"}
Tip #287 applies to Microsoft Word versions: 97 2000 2002 2003
Create and Merge! Using Word's mail merge tool you can quickly and easily combine data from a variety of data sources to create great individualized documents that incorporate your data in ways that you control. WordTips: Mail Merge Magic is an invaluable source for learning how to harness the full power of Word's mail merging capabilities.
Check out WordTips: Mail Merge Magic today!
Learn to search for and replace text, formatting, graphics, and special characters the easy way with WordTips: Find and Replace. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips