Are single field calcuations possible?

A

Angyl

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?
 
G

Greg Maxey

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.
 
A

Angyl

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.
 
J

Jean-Guy Marcil

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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top