The information in this article applies to:
SUMMARYWhen your data source contains a mixture of five- and nine-digit postal codes, you can use an IF field to evaluate and format the merged postal codes. MORE INFORMATION
Use one of the following methods to merge a data source containing a
mixture of five- and nine-digit postal codes:
Method 1: Determine Greater Than/Less Than 99999 MethodNOTE: Use this method only if your data source doesn't contain hyphens.
If the postal code data is larger than 99999, it is a number with more
than five digits. Therefore, it will be merged with the formatting switch
(\#). If it is equal to or less than 99999, it is a five-digit postal
code and will not include the formatting switch (\#) when merged.
Method 2: Calculation MethodNOTE: Use this method only if your data source contains hyphens.
The formatting of the first merge field has four number signs followed by
five number signs. This appears incorrect but is necessary for the
calculation that takes place.
This field code may not work if the postal code field is from a Microsoft
Access data source and if that field is formatted as a number. If the
postal code starts with a 0, for example "01234", Word interprets it as
"1234". To work around this behavior, format the postal code field as text
(rather than numbers) in Microsoft Access. Then postal codes beginning with
zero will be available in Word.
Word does not include fields that count the number of characters in another field. So, to determine the number of digits in the postal code field, the field construction in this method takes advantage of two facts: (1) when you format a numeric field to include a hyphen, the hyphen is treated by other fields as a subtraction sign; (2) numbers that begin with a zero are evaluated the same as numbers that don't begin with a zero. For example, "01234" is evaluated by Word as equal to "1234". The PostalCode field is placed in the main document with a hyphen, so that the formula can operate on it. Its absolute value is taken, which converts the number to a positive value. This new number is compared to the literal postal code. If the numbers differ, it's a nine-digit code and this is printed, with the format switch to keep any leading zeros. If the calculated number is different from the literal postal code, the postal code is printed as is (without the format switch). Additional query words: us u.s. post office zip zipcode 4Plus 4 Plus four printmerge mailmerge print mail 8.0 8.00
Keywords : kbfield winword kbmerge ntword macword word6 word7 word95 |
Last Reviewed: October 12, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |