Calculating based on text expressions in formfields - Word 2003

G

Guest

I use Word 2003. I've seen a lot of examples for math using formfields and
mergefields, but what if I want to evaluate an entry in one formfield in
order to diaplay certain TEXT in another formfield.

If you can follow my example, if it makes sense, what I'd like to do is this :

For the formfield named Text 2, the equation I want is this :
=if(Text1>1,"12","")

In other words, if Text1 is greater than 1, then Text2 should display "12",
else Text2 should display nothing. Instead of a result, I get a syntax error
on the quotes.

---------

Also what if I want to evaluate a TEXT entry in one formfield in order to
perform a calculation or display TEXT in another formfield?

For example, what's not working is this, for example in the formfield named
Text2 : =if(Text1="dog","has four legs",if(Text1="man","has two legs","")).
I get a syntax error on the quotes.

The above equation reads (I hope) as this : If Text1 equals "dog", then
Text2 displays "has four legs". If Text1 equals "man", then Text2 displays
"has two legs". If Text1 equals neither "dog" or "man", then Text2 displays
nothing.

What do I do?

Thanks.

- Eric
 
J

Jay Freedman

Leave out the commas. The fields should work as you've written them, with
that exception.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

I tried that. I set up my test document like this :

I opened a new document and clicked on the "text form field" box three
times, so I have three form fields ready to use, and they're automatically
named Text1, Text2, Text3. I then edit (right-click/Properties) the Text3
formfield : I change the TYPE to Calculation, and change the EXPRESSION to
one of the following :

=if(Text1="Dog" "Has Four Legs" "")
or
=if(Text1="Dog","Has Four Legs","")

I always get a syntax error on the quotes, so it's not the commas. Further
if I change the EXPRESSION to this by removing quotes :

=if(Text1=Dog,1,2)

I get the Undefined Bookmark, Dog error.

What to do?
Thanks.

- Eric

--------------------------------------
 
S

Suzanne S. Barnhill

Why are you using a calculated field at all? You can use an ordinary IF
field in the document (not in a form field), but note that the syntax of IF
fields does not include or tolerate commas between TrueText and FalseText.
Be sure to check "Calculate on exit" in the Form Field Options for the text
form fields.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

Great! It works!

Thank you. I'm new to all this. I have another question, related to your
answer. How do I reference a bookmark in the TrueText or FalseText? For
example how do I get : if m2 >1 HCPC "" to work? Meaning if the value in the
formfield named m2 is greater than 1 then display the value in the formfield
named HCPC, else display nothing.

Thank you.
 
J

Jay Freedman

Select the bookmark name and press Ctrl+F9, so you wind up with a
field nested within a field. Note that a field containing just a
bookmark name is really a Ref field; the keyword Ref is optional. So
you'll see the field code

{if m2 >1 {HCPC} ""}

and the inner field will evaluate to the content of the bookmark named
HCPC.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top