View Single Post
  #6   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

If you want to error check without macros then I suspect the best you can do
is to set the field result to 0 when the field is either empty or contains
text. Something along the lines of

{ SET A { IF { ={ Text66 } * 1 } = "!*" "0" "{ Text66 }" } }{ SET B { IF
{ ={ Text67 } * 1 } = "!*" "0" "{ Text67 }" } }{ SET C { IF { ={ Text68 }
* 1 } = "!*" "0" "{ Text68 }" } }{ IF { B } 0 "{ ={ A }/{ B } * { C }
\# ",0.00;-,0.00;" }" ""}

should do that.

Essentially it tests each field for numeric content by multiplying the field
result by a number (here 1) which will produce an error message that begins
with an exclamation mark. If the result is that exclamation mark it sets a
new bookmark with the value 0 or if not it sets the bookmark with the value
of the field. This is repeated for each field then the calculation is based
on the new bookmark names and not the field names. The only problem is there
is no feedback to the user if he makes the type of error you have raised.


--

Graham Mayor - Word MVP

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




Kima & Greg Schwend wrote:
Thank you for the help,

Adding the default value of zero to each of the three number fields
has successfully produced the result of a blank field or a number. I
think part of the solution was for me to skip toggling the field code
to hide the formula before protecting the form. I skipped that and
went straight to protecting the form which hid the code for me.

But there are a couple problems. If a form user overtypes the default
0 in one of the three number fields then deletes any typing in that
field (blank field) then I get the !Syntax Error.

If a user types in text into a number field then I get an !Undefined
Bookmark error.

How can I trap these errors? I can't use macros because of the user
base. And I don't want to import from Excel.

Thank you.