WD: How to Use a Conditional Field to Specify a Number of Digits

Last reviewed: February 3, 1998
Article ID: Q142778
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word for Windows NT, version 6.0

SUMMARY

This article describes how to specify a numeric format switch within a nested {IF} field to control the number of leading zeros in a numeric result. The formula allows you to format numbers that contain an unequal number of digits, such as 10, 100, and 1000, as numbers that contain an equal number of digits, such as 0010, 0100, and 1000.

MORE INFORMATION

Use a numeric picture switch (\#) to specify the number of digits for the result. For example, if your number is to contain five digits, use the following numeric picture switches within the conditional formula:

   \# 0000#
   \# 000##
   \# 00###
   \# 0####

Create the following conditional {IF} field:

{if { mergefield number } > "10" { if { mergefield number } > "100" { if { mergefield number } > "1000" { mergefield number \# 0#### } { mergefield number \# 00### } } { mergefield number \# 000## } } { mergefield number \# 0000# } }


Additional query words: nested conditional 8.0 8.00
Keywords : kbfield macword ntword winword word6 word7 word8 word95 word97 wordnt
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a,97;MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.