Form Field IF Calculation

M

MacSandy

Version: 2004
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I'm trying to create a Memorandum of Understanding template that others users can simply fill in. I've created a form with various fields in either fill-in text or drop-down format. I want to put an IF calculation into one of the form fields using the calculation option. Is this possible? If so, what does the syntax look like? (I'm assuming it looks rather different than an excel formula since it is embedded in a form field.)

My calculation would read as follows: IF PledgeTerm (previous form field) = one then print "Payment" otherwise print "The original payment".

Thanks for any suggestions!
Sandy
 
P

Peter Jamieson

1. There are several ways to go about it:

2. Whatever you do, when you are in design mode, select the properties
of the pledgeterm field and ensure that "Calculate on exit" is checked.

3. You do not have to use a form field to display the "Payment" text.
You could for example use the field

{ IF PledgeTerm = 1 "Payment" "The original payment" }

(The {} need to be Word's special field code braces - if you can't work
out how to enter them on your Mac, copy an existing field, strip the
text out, enter the text you need, then select and update the field).

This field should be recalculated when the user tabs out of PledgeTerm.

NB, I don't know what you are actually comparing with. If it's "one",
you might need

{ IF PledgeTerm = "one" "Payment" "The original payment" }
or if the user could enter upper/mixed case, perhaps
{ IF { REF PledgeTerm \*lower } = "one" "Payment" "The original payment" }

where each pair of {} needs to be those special braces.

If you know the result will be numeric you could also consider using e.g.

{ =PledgeTerm-1 \#"'The original payment';'The original
payment';'Payment'" }

To get back to your original question, these { = } "Expression" fields
do not use Excel formulas. They use Word's own formula syntax which is a
lot more limited. You can find out more in Word Help.

4. If you need to use a form field, AIUI you have two options. Either
way, ensure that you select the properties of the formfield and set the
type to "Calculation". Then you will see that you can enter a formula
starting with "=". In fact you should be able to enter exactly the same
formula as the =PledgeTerm - 1 example above, with the formatting switch
\# etc., as above, but you do not have to enter the {}.

This is, if you like, the "Supported" method. However, if you need to go
beyond the capabilities of an {=} field, you can in fact use any field
code. You just can't insert it in the Expression box in the field code's
properties, and Word will throw it away if you ever use the Edit
Properties dialog for that formfield again. So this is probably not such
a great idea, but...
a. if you enter the Expression using an {=} field, then toggle the
field code display for the form fields, you will see something like

{ FORMTEXT { =PledgeTerm-1 \#"'The original payment';'The original
payment';'Payment'" } }

i.e. that "Expression" is simply a calculation field nested inside the
FORMTEXT field. You can for example replace it by the IF field I
described earlier.

Finally, when referencing other form fields in = Expressions, you should
be OK using the name alone, i.e. "PledgeTerm". However, in the more
general case (e.g. in the example where we used \*lower) you may need
either { PledgeTerm } or { REF PledgeTerm }.


Peter Jamieson

http://tips.pjmsn.me.uk
 

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