• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Subtracting values between two fields

Here are some quick points:

field1, "firstnumber" = number/editable
field2, "secondnumber" = number/editable
field3, "resultnumber" = number/computed

User enters a number value in field1
User enters a number value in field2
Field3 automatically shows the value of field1 minus field2

What formulas do I need in all three fields for this to work, including checking to make sure that user enters a number, (as opposed to text), etc.?
0
jtpatten
Asked:
jtpatten
  • 4
  • 3
  • 3
1 Solution
 
qwaleteeCommented:
You don't need any formula in the first and second, Notes will take care of validating that they are numbers.

In the third, the formula should be:

result := firstNumber - secondNumber;
@If(@IsError(result); ""; result)
0
 
HemanthaKumarCommented:
Usually if you enter data type other than defined by field information.. the app will automatically raise the data type mismatch errors.

The formula is quiet simple.. in the default value section of the field3 enter this formula

@If(@IsNumber(Field1) & @IsNumber(Field2); FIELD1 - FIELD2; 0)

~Hemanth
0
 
jtpattenAuthor Commented:
qualetee,

Notes accepts this but nothing shows in the result field when numbers are entered and the form is refreshed?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
jtpattenAuthor Commented:
HemanthaKumar,

Your answer seems to always post a zero in the results field no matter what is entered in the other two fields?
0
 
jtpattenAuthor Commented:
HemanthaKumar,

Sorry, your answer does work, I had something else hosed.

Respond back so I can accept for you.

Thanks,

Jack
0
 
HemanthaKumarCommented:
The problem is the computed field will not just refresh unless something triggers

1. Hit F9 key to manually refresh
2. When you exit of field2, write a script which triggers a refresh

Dim ws as New NotesUIWOrkspace
ws.UIDocument.Refresh

0
 
jtpattenAuthor Commented:
HemanthaKumar

What would I have to add to the results field formula so that if there is nothing entered in the first two fields the results field will show blank?

Right now it shows a zero.
0
 
qwaleteeCommented:
Use my formula, and it will show blank.  Use Hemantha's formula, it will show zero.
0
 
HemanthaKumarCommented:
@If(@IsNumber(Field1) & @IsNumber(Field2); FIELD1 - FIELD2; "")
0
 
qwaleteeCommented:
If this is  VERY SIMPLE form, you can also enable th form property, "Automatically Refresh Fields," which would update as soon as you tab out of field 2.

This isn't work for a Notes AD I class, is it?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now