IF expression1 operator expression2 truetext falsetext [switches] |
Compares two values and then inserts the text appropriate to the result of the comparison. |
expression1 | Values you want to compare. |
expression2 | Values you want to compare. |
operator | Comparison operator: = Equal to <> Not equal to > Greater than < Less than >= Greater than or equal to <= Less than or equal to |
truetext | The text you want to appear when the comparison is True. |
falsetext | The text you want to appear when the comparison is False. |
switches | |
\* upper | ??? |
\* lower | ??? |
\* firstcap | ??? |
\ *caps | ??? |
REMARKS |
* The "expression1" can be a bookmark name, strings of characters, numbers, nested fields that return a value, or mathematical formulas. * The "expression2" can be a bookmark name, strings of characters, numbers, nested fields that return a value, or mathematical formulas. * If either of the expressions contains spaces, enclose the expression in quotation marks. * You must insert a space both before and after the operator * If "falsetext" isn't specified and the comparison is false, the IF field has no result. Each string containing multiple words must be enclosed in quotation marks. * If "falsetext" isn't specified and the comparison is false, the IF field has no result. Each string containing multiple words must be enclosed in quotation marks. * If used in a mail merge main document, the IF field can examine information in the merged data records, such as postal codes or account numbers. For example, you can send letters to only those clients located in a particular city. * If the operator is = or <>, Expression2 can contain a question mark (?) to represent any single character or an asterisk (*) to represent any string of characters. Expression2 must be enclosed in quotation marks so that it's compared as a character string. If you use an asterisk in Expression2, the portion of Expression1 that corresponds to the asterisk and any remaining characters in Expression2 cannot exceed 128 characters. * IF fields perform one of two alternative actions, depending on a condition you specify. For example, the statement "If the weather is sunny, we'll go to the park; if not, we'll go to the movies" specifies a condition that must be met (sunny weather) for a certain action to take place (going to the park). If the condition is not met, an alternative action occurs (going to the movies). * This field is used regularly to test a mathematical statement that retrieves a value from a bookmark. * Word inserts an IF field in this form when you click the Insert Word Field button on the Mail Merge toolbar and then click If...Then...Else. * For the Microsoft documentation refer to support.microsoft.com |
Examples |
{ IF True "This is True" "This is False" } { IF {DocVariable "Team" }=False "Individual" "Group" \* MERGEFORMAT } { IF order>=100 "Thanks" "The minimum order is 100 units" } { IF { MERGEFIELD Rate } = { MERGEFIELD Discount } "We will offer you a larger discount. " " " } { IF { MERGEFIELD State } = "NY" "{ INCLUDETEXT c:\\worddocs\\contract.doc }" "{ AUTOTEXT Copyright }" } { IF { MERGEFIELD Company } <> " " "{ MERGEFIELD CompanyAddress }" "{ MERGEFIELD HomeAddress }" } { IF { = { MERGEFIELD Balance } - {MERGEFIELD Payment } } > 0 "Your current balance is { = { MERGEFIELD Balance } - { MERGEFIELD Payment } \# "$#,##0.00;($#,##0.00) " }." "Your account is paid in full. Thank you." } { IF { = AND ( { COMPARE { MERGEFIELD CustomerNumber } >= 4 }, { COMPARE { MERGEFIELD CustomerRating } <= 3 } ) } = 1 "Satisfactory" "Unsatisfactory"} {IF {MERGEFIELD State} = "CA" "For California residents, we offer special rates to Asia and Japan." "{IF {MERGEFIELD State} = "WA" "For Washington residents, we offer special rates to Asia and Japan." " "} "} { IF CurrentRate < LoanRate "You may want to consider refinancing your loan." " " } |
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top