View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default puzzling number format problem in conditional field

Word does not have any default formatting for currency numbers.

See "Formatting Word fields with switches" on fellow MVP Graham Mayor's
website at

http://www.gmayor.com/formatting_word_fields.htm

Your field construction of

{IF { MERGEFIELD country} = "United States", "{MERGEFIELD ttl_price
\###.00}" "" }

should be

{IF { MERGEFIELD country} = "United States", "{MERGEFIELD ttl_price \#
",#.00"}" "" }

assuming that you do not want the $ sign to appear.

If after making that correction, the fields still disappear, it is probably
because they need updating for the effect of the If...then...Else
construction to be displayed.

With the above construction, you will not of course get any result if the
country is not the USA.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Jesse" wrote in message
...
I am doing a Word mailmerge with an Access database -- Office 2000.
The problem has to do with currency fields in the database and getting
the \# formatting to work.

Based on what I see, Word has default formatting for currency numbers
- putting a dollar sign in front of them unless you tell Word
otherwise. I have been able to override this by using a format
switch. So:

{MERGEFIELD ttl_price \###.00}

However, when I add this switch to this mergefield within a
conditional statement -

{IF { MERGEFIELD country} = "United States", "{MERGEFIELD ttl_price
\###.00}" "" }

- the formatting code disappears when I switch to "View merged data"
and back - and so it has not effect.

A workaround has been to add the mergefield to zero, and then the
formatting will stick and work:

{ = {MERGEFIELD ttl_price} + 0 \# ##.00 }

However, this causes a troublesome blank space to appear before the
number.

Another workaround, which is the most puzzling to me (as to why it
works): I create {MERGEFIELD ttl_price \###.00} outside the IF
statement and then paste it inside the statement,. Even with this
approach, every mergefield that I want within the IF statement has to
be pasted in as a block; if I just past in 1 field after others are
there, the new 1 filed disappears.

Please note, all of the { } brackets are created by doing an insert -
i.e., not by typing the brackets. AFAIK, when adding a mergefield one
has to manually add in the formatting - i.e., there is no "insert
field switch format picture", so entering it by typing should work.

Also, in order to try to suppress Word adding a $, I did try changing
the field type in Access from currency to number, but then anything
right of the decimal was dropped.

Any ideas as to why there is a problem formatting within the IF
statement? Especially, why creating the code outside the IF statement
and then pasting it in works? Thanks. -- Jesse.