Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the numeric values from Calculate fields

Status
Not open for further replies.

barnard90

IS-IT--Management
Mar 6, 2005
73
US

Hi
I have certain form fields in a Word Document. They are Regular Text Form Fields and Calculated Form Fields


The Calculated Field is for calculating amount , which is
Principal + Interest

The formula of Calculated field ( Amount ) is
= Principal + Interest
( Principal and Interest ) are the two Regular Text fields .
Now this works fine , but gives an error whenever a non numeric value is entered into either Principal or Interest.
These fields are already designed as Regular text fields and not Number form fields are they are not changed .

Can I have a formula like
Isnumeric(Principal) + Isnumeric(Interest ) ?

The Calculated field has to calculate only if numeric values are entered in the Principal and Interest fields

Could some one please suggest a solution?
Thanks
 
You could do like you are thinking, I would suppose.

Something like:

Code:
If Isnumeric(Principal) AND Isnumeric(Interest ) Then
   'Do the math
Else
   'Don'd do the math
End If

You would put this in whatever event you are wanting to use. If you are wanting to do that within the text box itself... not sure, will see and post back..
 
I believe this would work if you want to put it directly in the calculated portion of your text box:
Code:
=IIf(IsNumeric([txt1]),IIf(IsNumeric([txt2]),[txt1]+[txt2]))
 
Well, it seems that does work, except it is concatenating a string instead of adding the numbers... one moment..
 
Hmm, I tried changing to using .Value instead of just the text box names, but it is still concatenating...

Will post back if I get it nailed down 100%.
 
What is really weird is that it works fine in the "default value" property, but not in the "control source" property..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top