View Single Post
  #8   Report Post  
Posted to microsoft.public.word.tables
Kima & Greg Schwend Kima & Greg Schwend is offline
external usenet poster
 
Posts: 6
Default IF field with a formula

On Aug 22, 2:56*am, "Graham Mayor" wrote:
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;" }" "Incorrectfielddata entry!" }" ""}

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

--

Graham Mayor - *Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org




Graham Mayor wrote:
Ifyou want to error check without macros then I suspect the best you
can do is to set thefieldresult to 0 when thefieldis 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 eachfieldfor numeric content by multiplying
thefieldresult by a number (here 1) which will produce an error
message that begins with an exclamation mark.Ifthe result is that
exclamation mark it sets a new bookmark with the value 0 orifnot it
sets the bookmark with the value of thefield. This is repeated for
eachfieldthen the calculation is based on the new bookmark names
and not thefieldnames. The only problem is there is no feedback to
the userifhe 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 blankfieldor a number. I
think part of the solution was for me to skip toggling thefieldcode
to hide theformulabefore 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.Ifa form user overtypes the default
0 in one of the three number fields then deletes any typing in that
field(blankfield) then I get the !Syntax Error.


Ifa user types in text into a numberfieldthen 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.- Hide quoted text -


- Show quoted text -


Thank you,

That suggestion for error trapping does everything I need for this
form. I really appreciate your help.

Greg