Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Word mailmerge how to do multiple If statements

If you use Alt-F9 to show the field codes in each gen?.doc, you would see
something like

{ MERGEFIELD Name }
{ MERGEFIELD Addr1 }
{ MERGEFIELD CPP }

{ MERGEFIELD Sal }

. . . . then the body text.

Assuming you want each of those MERGEFIELD lines to be removed when they are
blank, you could use

{ IF { MERGEFIELD Name } = ""
"" "{ MERGEFIELD Name }
" }{ IF { MERGEFIELD Addr1 } = ""
"" "{ MERGEFIELD Addr1 }
" }{ IF { MERGEFIELD CPP } = ""
"" "{ MERGEFIELD CPP }
" }

{ IF { MERGEFIELD Sal } = ""
"" "{ MERGEFIELD Sal }
" }
. . . . then the body text.

As I've probably said before, each of the pairs of {} need to be the special
field braces you can insert using ctrl-F9. Everything else is plain text. It
doesn't really matter how you lay out the IF fields as long as there's a
paragraph mark immediately after the { MERGEFIELD } in the result and the
following text follows straight on. e.g. you can use

{ IF { MERGEFIELD Name } = "" "" "{ MERGEFIELD Name }
" }{ IF { MERGEFIELD Addr1 } = "" "" "{ MERGEFIELD Addr1 }
" }{ IF { MERGEFIELD CPP } = "" "" "{ MERGEFIELD CPP }
" }

but not

{ IF { MERGEFIELD Name } = "" "" "{ MERGEFIELD Name }" }{ IF { MERGEFIELD
Addr1 } = "" "" "{ MERGEFIELD Addr1 }" }{ IF { MERGEFIELD CPP } = "" "" "{
MERGEFIELD CPP }" }

or

{ IF { MERGEFIELD Name } = "" "" "{ MERGEFIELD Name }
" }
{ IF { MERGEFIELD Addr1 } = "" "" "{ MERGEFIELD Addr1 }
" }
{ IF { MERGEFIELD CPP } = "" "" "{ MERGEFIELD CPP }
" }

(I usually do it the first way because it has more chance of getting through
these newsgroups unchanged)

Peter Jamieson


"Peter" wrote in message
...
Hi Peter,

I guess for me, the confusion is where to place the information about the
actual fields in my Gen.doc within the If statement.

I have 4 different documents to begin with; Gen, Gen2, Gen3, Gen4. Within
each document I have 4 merge fields as so:

Name
Addr1
CPP

Sal

. . . . then the body text.

The field "Alert" does not appear in the document but is only used as
reference for type of letter.

So in your example of:

{ IF "{ MERGEFIELD ALERT }"= "" ""
"{ IF "{ MERGEFIELD ALERT }" = "GEN"
"{INCLUDETEXT"C:\\Mer\\Gen.doc"}"
"{MERGEFIELD ALERT}
"}then stuff that should be on the next line

I am confused about placement of the acutal data fields used in Gen, Gen2,
Gen3, Gen4, to suppress blank lines.

I will completely understand if you're getting frustrated with trying to
get
the concept through my thick skull . . . so feel free to throw your hands
up
and proclaim "what an idiot!" . . . lol

Thanks again for your time Peter.

Peter






 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
if statements with dates in mailmerge walkerh Mailmerge 3 April 9th 07 06:17 PM
How do I insert multiple hyperlinks in if, then, else statements? QUCJ Microsoft Word Help 0 September 21st 05 01:52 PM
How do i use multiple IF statements in word 2000? dg Mailmerge 1 August 18th 05 06:24 AM
MERGE: Can I have multiple SET statements based on one IF Bill Anderson Mailmerge 1 February 24th 05 06:03 AM
MERGE: Can I have multiple SET statements based on one IF Bill Anderson Mailmerge 0 February 24th 05 01:27 AM


All times are GMT +1. The time now is 11:16 PM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"