View Single Post
  #4   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default IF field with a formula

For the calculation to work as Doug intended, without the syntax errors
caused by calculation empty fields, it would be necessary to set the 3 Text
field types to 'Number' and put in a default value of 0.

{ IF{ Text67 } 0 { = { Text66 } / { Text67 } * { Text68 } \#
",0.00;-,0.00;" } "" }

The above should then work to two decimal places. However note that the
commas and semi-colons used in the formatting switch -
",0.00;-,0.00;"
are language specific - here English - and the switch will produce some odd
results if you use the wrong thousands and list separators for your local
language.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Kima & Greg Schwend wrote:
On Aug 21, 1:00 am, "Doug Robbins - Word MVP"
wrote:
Use

{ IF { Text67 } 0 { = { Text66 } / { Text67 } * { Text68 } \#
.00;-0.00; } "" }

It does not have to be in a formfield, but for Text66, Text67 and
Text68 you
will need to check the Calculate on Exit box.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Kima & Greg Schwend" wrote in
...



I have a table that contains form fields that are bookmarked. I want
to use an IF field to prevent a divide by zero error and to display
the result of an equation.


The fields are defined as number fields and bookmarked Text66,
Text67, and Text68.


The formula is =Text66/Text67*Text68


The formula works if I don't use the IF statement. But I want to
display nothing if Text67 is blank or 0.


{ IF Text67 0 =Text66/Text67*Text68 \# "0.00" ""}


This just displays =Text66/Text67*Text68 if Text67 is greater than
0. I've tried to use an extra set of brackets to contain the true
result (by pressing ctrl+F9) but that doesn't work, nor does
containing the true result with quotes.


How can I display my true result as a number and not text?


Thanks- Hide quoted text -


- Show quoted text -


Thank you Doug, but it doesn't seem to work.

I typed in your suggestion, using ctrl+F9 to open each bracket. Then I
right clicked and selected 'toggle the field code' to hide the IF
field. I protected my form and filled in the three fields related to
this formula (all have calculate on exit selected). The IF field
shows !Syntax Error, * after filling in the first field; !Unexpected
End of Formula after filling in the second field; a partial result
after filling in the third field. That partial result was the division
part of the formula without the multiplication (Text66/Text67). But
after clearing the three fields and then re-entering them the result
displayed is an incorrect .00

Now I filled in 10, 5, 6 for the text66 thru 68 fields then If I
toggle the field code to view what I typed in then this is displayed:
{ IF 5 0 { = 10 / 5 * 6 \#.00:-0.00; } "" }

I can't seem to view everything I typed in for the IF field. I can use
'Toggle field code' twice to display some of the nested brackets. But
I can't use the 'Edit field' selection from the right click menu.

I know this is simple in Excel, but I have some complicated formatting
in my Word 2003 document and I want to avoid inserting from Excel.

Thanks