View Single Post
  #2   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 How to write {} statments with IF MAILMERGE?

While you might get by using mailmerge to do this, you should really
consider using an Access report.

However, the If...then...Else field construction with Mergefields would be

{ Mergefield "Item1" }{ IF { Mergefield "Item2" } "" [Enter]
{ Mergefield "Item2" }{ IF { Mergefield "Item3" } "" [Enter]
{ Mergefield "Item3" } "" } "" }

Where the [Enter] appears above, you need to press the Enter key at that
point when constructing the field code

--
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

"lbmmoh" wrote in message
...

Im a newb here, and trying to write a mailmerge that pulls data from an
excel file.

I have it working, but I get blanks in my letter where the recipient
isnt making that purchase.

for example right now I have lots of items that dont always get filled
because they are blank in my database:

Hello thanks for your order:

{MERGEFIELD "Item1"}
{MERGEFIELD "Item2"}
{MERGEFIELD "Item3"}

Your order will be shipped out ASAP.

If I have a customer with just Item1 purchase, then there is a 2 blank
lines before the "Your order..." line starts. I understand that I need
an IF statment to get rid of the gap but I dont know how to write it. I
see that I have to hit control f9, but when I do that after my current
MERGEFIELD, I get too many of the {} symbols.

My question is simply trying to understand how to use the control F9
and when to do it, so that I have the right amount of symbols.

The code should look like:

{MERGEFIELD "Item1"}{ }{IF {MERGEFIELD "Item1"} ""
etc
etc

But again, I cant get the right amount of { } or I get too many. Am i
missing a fundamental way in editing a MERGEFIELD that is already in my
document? Im using Word 2007

Thanks!




--
lbmmoh