my IF field doesn't quite work with text as expression

  • Thread starter Thread starter Joyce
  • Start date Start date
J

Joyce

I have a dropdown field called (ProductType) with product
A, product B, Product C and so on.
I am trying to insert an "IF" field when a product is
selected in the dropdown menu then it returns with a 1
line description for each product.

I started with a simple field code looks like this:
{IF ProductType = "Product A" "This is our best
product" "" \* MERGEFORMAT }

This doesn't work. But if the 2nd expression is a number
then it works!

What is wrong with this formula?
And how do I set up multiple IF statements in the same
field for each different product selected to return
different discription?

Joyce
 
Joyce,

What do you mean by "if the second expression is a number then it works"?
Based on my observations wouldn't it be more correct to say that if the
second expression is a number it still doesn't work but at least the IF
field returns the number :-)

Try { IF {REF ProductType} = "a""This is out best product"} Note you don't
need the pair of empty speech marks.

To achieve your OR statement you need to use nested IF fields. e.g.,
{ IF {REF ProductType} = "a""This is out best product""{ IF { REF
ProductType} = 'b""This is our worst product""{IF {REF ProductType} =
"c""This product would do in a pinch"}}}
 
Another way to do it would be to use the following in a macro run on exit
from the dropdown

' Macro created 15-11-97 by Doug Robbins to add the address corresponding to
a drop down name

'

Set myDrop = ActiveDocument.FormFields("Dropdown1").DropDown

Company = myDrop.ListEntries(myDrop.Value).Name

Address = ActiveDocument.AttachedTemplate.AutoTextEntries(Company).Value

ActiveDocument.FormFields("Text1").Result = Address


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
Greg,

I tried your version but it only return "ProductType}" no
matter what is selected.


When I say the second expression is a number I mean this:
{IF ProductType = 80 "This is our best product" \*
MERGEFORMAT }
So if I select "80" from the dropdown list then it retuns
the statement.

Any thoughts?

cheers,
Joyce
 
Joyce,

Trying to post these nested IF field examples is difficult as there is no
way to test them in the news groups. There are undoubtably typing errors in
the string I gave you (one for sure is the ' vice " in front of b) but the
concept is sound.

The basic field is:

{ IF {REF PT} = "a""Something""Something else"}

Replace "Something else" in the string above with

{ IF {REF PT} = "b""Something""Something else"}

Replace "Something else" in the sting above with

{ IF {REF PT} = "c""Something""Something else"}
 
Back
Top