How do I get a form field to perform a calculation on a number that the user
puts in it?

I know how to do it with multiple fields like =(Field1)*(Field2) but what if
I want it to equal what the user puts in this field itself /12, for example?

so If I have one field in a document that is supposed to display how much
the average person makes in a year based on an hourly rate. The field would
need to accept the user's input (the hourly rate) and automatically multiply
that number by 2080 and the change what they inputted to show the result.

is that possible?

Re: Are single field calcuations possible? by Greg

Greg
Thu Aug 31 12:19:47 CDT 2006

Perhaps:
Sub OnExitText1()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
oFld("Text1").Result = Val(oFld("Text1").Result) * 2080
End Sub

Would you really want to do this? I mean if I enter data in a field, I
would be surprised if not annoyed to see it change as I exit the field.





Angyl wrote:
> How do I get a form field to perform a calculation on a number that the user
> puts in it?
>
> I know how to do it with multiple fields like =(Field1)*(Field2) but what if
> I want it to equal what the user puts in this field itself /12, for example?
>
> so If I have one field in a document that is supposed to display how much
> the average person makes in a year based on an hourly rate. The field would
> need to accept the user's input (the hourly rate) and automatically multiply
> that number by 2080 and the change what they inputted to show the result.
>
> is that possible?


Re: Are single field calcuations possible? by Angyl

Angyl
Thu Aug 31 12:42:02 CDT 2006

LOL. I know what you mean by being annoyed but it would be expected by the
user. We receive a form from a company that projects a YEARLY amount due for
Worker's comp insurance and it calculates everything out on a yearly basis
but we want to know what it is on a MONTHLY basis. Every client has an
expense constant (now it's usually $180/year, but not always), so my user
will be putting that expense constant in at $180 but that's the yearly
rate... we want monthly. So if I have the field automatically /12 that
number and it changes it will make for accuracy without the hassle of a
second field, and I can continue my calculations from there.

Thanks again, Greg.

"Greg Maxey" wrote:

> Perhaps:
> Sub OnExitText1()
> Dim oFld As FormFields
> Set oFld = ActiveDocument.FormFields
> oFld("Text1").Result = Val(oFld("Text1").Result) * 2080
> End Sub
>
> Would you really want to do this? I mean if I enter data in a field, I
> would be surprised if not annoyed to see it change as I exit the field.
>
>
>
>
>
> Angyl wrote:
> > How do I get a form field to perform a calculation on a number that the user
> > puts in it?
> >
> > I know how to do it with multiple fields like =(Field1)*(Field2) but what if
> > I want it to equal what the user puts in this field itself /12, for example?
> >
> > so If I have one field in a document that is supposed to display how much
> > the average person makes in a year based on an hourly rate. The field would
> > need to accept the user's input (the hourly rate) and automatically multiply
> > that number by 2080 and the change what they inputted to show the result.
> >
> > is that possible?
>
>

Re: Are single field calcuations possible? by Jean-Guy

Jean-Guy
Thu Aug 31 12:43:29 CDT 2006

Angyl was telling us:
Angyl nous racontait que :

> How do I get a form field to perform a calculation on a number that
> the user puts in it?
>
> I know how to do it with multiple fields like =(Field1)*(Field2) but
> what if I want it to equal what the user puts in this field itself
> /12, for example?
>
> so If I have one field in a document that is supposed to display how
> much the average person makes in a year based on an hourly rate. The
> field would need to accept the user's input (the hourly rate) and
> automatically multiply that number by 2080 and the change what they
> inputted to show the result.
>
> is that possible?

As Greg wrote, it would be better to have two fields. One for user input,
and the result in a calculated field.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org