Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
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
Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective.