Re: IF field with a formula

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On further reflection and assuming that your numbers are less than a
million, you could trap a bit more thoroughly and give the user some
feedback, but the limit is the possibility that Text67 may have a 0 value so

{ SET A { IF { ={ Text66 } * 1 } = "!*" "9999999" "{ Text66 }" } }{ SET B
{ IF { ={ Text67 } * 1 } = "!*" "0" "{ Text67 }" } }{ SET C { IF { ={
Text68 } * 1 } = "!*" "9999999" "{ Text68 }" } }{ IF { B } <> 0 "{ IF{
={ A }/{ B } * { C }} < 1000000 "{ ={ A }/{ B } * { C } \#
",0.00;-,0.00;" }" "Incorrect field data entry!" }" ""}

You will still get no feedback if an incorrect entry is made in Text67 - and
I cannot immediately see a way around that.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

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



Graham Mayor wrote:
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.


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.


.



Relevant Pages

  • Re: IF field with a formula
    ... can do is to set thefieldresult to 0 when thefieldis either empty ... sets the bookmark with the value of thefield. ... The only problem is there is no feedback to ... went straight to protecting the form which hid the code for me. ...
    (microsoft.public.word.tables)
  • Re: Form Initialization
    ... (TextBox1) ... or something similar to trap the error if the bookmark doesn't exist. ... Jay Freedman ...
    (microsoft.public.word.vba.general)
  • Re: Frameset Borders
    ... interested in the quirks of frames, can bookmark it etc. ... Google retains these usenet topics long ... Thanks for the feedback though. ...
    (alt.html)
  • Re: New tool to check TFRs
    ... > Hope it helps, and feedback is appreciated. ... Why can't the FAA make something this nice? ... I like the fact you can bookmark your common routes by typing in your ... Prev by Date: ...
    (rec.aviation.piloting)
  • Re: Customize "Cut/Copy and Paste Special" commands
    ... You can trap the EditCut and EditCopy commands to check if the ... redefine a bookmark in the pasted text, if you knew that one was required. ... target document already has a bookmark with the name used, ...
    (microsoft.public.word.vba.customization)