Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / December 2007

Tip: Looking for answers? Try searching our database.

IF statement in a merge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kathy Webster - 27 Dec 2007 20:07 GMT
Hmm...how do I explain this...

I want the merge document to include the {MERGEFIELD Signatory} if and only
if...

1. {MERGEFIELD SigBarNo} does not equal {MERGEFIELD A1Bar} and
2. {MERGEFIELD SigBarNo} does not equal {MERGEFIELD A2Bar} and
3. {MERGEFIELD SigBarNo} does not equal {MERGEFIELD A3Bar}

If {MERGEFIELD SigBarNo} equals any of the above, I want {MERGEFIELD
Signatory} to be omitted.

TIA and happy holidaze,
Kathy
Peter Jamieson - 28 Dec 2007 00:07 GMT
Try

{ IF "{ MERGEFIELD SigBarNo }" <> "{ MERGEFIELD A1Bar }"
"{ IF "{ MERGEFIELD SigBarNo }" <> "{ MERGEFIELD A2Bar }"
"{ IF "{ MERGEFIELD SigBarNo }" <> "{ MERGEFIELD A3Bar }"
"{ MERGEFIELD Signatory }" "" }" "" }" "" }

where all the {} are the special field code braces you can enter using
ctrl-F9 and everything else is plain text.
(It can all be on one line if you want).
Signature

Peter Jamieson
http://tips.pjmsn.me.uk

> Hmm...how do I explain this...
>
[quoted text clipped - 10 lines]
> TIA and happy holidaze,
> Kathy
Kathy Webster - 28 Dec 2007 00:33 GMT
I tried to no avail.  I am aware of the Ctrl-F9 code brace technique.
I triple checked my work before writing back.
Do spaces before/after brackets matter?

> Try
>
[quoted text clipped - 20 lines]
>> TIA and happy holidaze,
>> Kathy
Peter Jamieson - 28 Dec 2007 01:05 GMT
> Do spaces before/after brackets matter?

If you lay it out the way I did you should be OK.The statement could
typically be simplified or reduced in various ways, e.g. drop the quotes
around the MERGEFIELD fields, especially if the MERGEFIELD rresults are
always numeric and are always represented the same way, e.g. "2" is always
"2" and not "02"

{IF "{MERGEFIELD SigBarNo}" <> "{MERGEFIELD A1Bar}"
"{IF "{MERGEFIELD SigBarNo}" <> "{MERGEFIELD A2Bar}"
"{IF "{MERGEFIELD SigBarNo}" <> "{MERGEFIELD A3Bar}"
"{MERGEFIELD Signatory}" ""}" ""}" ""}

should also be OK.

What hapens if you start with a really simple expression, e.g.

{ IF "{ MERGEFIELD SigBarNo }" <> "{ MERGEFIELD A1Bar }" "{ MERGEFIELD
Signatory }" "" }

or

{ IF "{ MERGEFIELD SigBarNo }" = "{ MERGEFIELD A1Bar }" "" "{ MERGEFIELD
Signatory }" }

? Does either of them work as you expect? If not, can you use Alt-F9 to
reveal the field codes, select each of the inner mergefield fields in turn,
and use the right-click menu to toggle field codes? You should then be able
to see the inner results and make sure they are as you expect.

Do you have any SKIPIF fields in your mail merge main document?

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

>I tried to no avail.  I am aware of the Ctrl-F9 code brace technique.
> I triple checked my work before writing back.
[quoted text clipped - 24 lines]
>>> TIA and happy holidaze,
>>> Kathy
Kathy Webster - 28 Dec 2007 01:03 GMT
Figured it out. Took off quotes on all except "{MERGEFIELD Signatory}" and
it worked. Thank you!

> Try
>
[quoted text clipped - 20 lines]
>> TIA and happy holidaze,
>> Kathy

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.