Using the IF condition in mal merge

Mawallace
Mawallace used Ask the Experts™
on
I have a merge field.

I want this to print a sentence if the numerical value of a merge field is positive,.

If negative I want another sentence to be added.

How can this be done?

I have been playing with the IF command - but to no success
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
GrahamSkanRetired
Top Expert 2012

Commented:
If this is a tristate situation, i.e. no sentence if the value is zero, it would be simpler to use two IF tests:

{IF {MERGEFIELD Myfield} > 0 "Positive sentence."}{ IF {MERGEFIELD Myfield} < 0 "Negative sentence."}
GrahamSkanRetired
Top Expert 2012

Commented:
If you want zero to be included with the positives:
{ IF {MERGEFIELD Myfield} < 0 "Negative sentence." "Positive sentence."}

If you get any complex field representations posted here, you might like to use the macro in this article to convert to actual fields after you have pasted the text on to your document:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/A_7236-Macro-code-to-convert-text-to-fields-in-Microsoft-Word.html

Author

Commented:
This is what is in the document! I thought - but it returns the value >0

I think it is the way I entered the mergefeld

Can you give me some advice- document below 2nd line (I used "p" or "n")
a34mqub9.doc
Retired
Top Expert 2012
Commented:
You need spaces to separate the test , true and false parts of the IF field. This is what yours looks like:

{ IF {MERGEFIELD LMCLIsCYrBalRepay } > 0"p""n"}

This is what it needs to look like
{ IF {MERGEFIELD LMCLIsCYrBalRepay } > 0 "p" "n"}

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial