Answered by:
Text Box value

>
Question
-
I have 3 text boxes (A, B, C)
C = A - B BUT the answer must always be 0 if the A - B produce a negative number.
I know I can do this with a button, but is there a way to do it without one. Like write a function under Default Value?
Thanks for the help.Wednesday, July 15, 2009 6:16 PM
Answers
-
Sure, use rules.
On box B, create these rules that say
If A is not empty and B is not empty and A-B < 0, then set field C's value to 0
If A is not empty and B is not empty and A-B >= 0, then set field C's value to the formula A-B
There may be more you want to do, but those should work without the need for a button or default value.
SharePoint Architect || My Blog- Marked as answer by Dahey Wednesday, July 15, 2009 7:32 PM
- Unmarked as answer by Dahey Wednesday, July 15, 2009 7:36 PM
- Proposed as answer by Alec Pojidaev Wednesday, July 15, 2009 7:43 PM
- Marked as answer by Dahey Wednesday, October 5, 2011 9:55 PM
Wednesday, July 15, 2009 6:21 PM -
- Edited by Alec Pojidaev Wednesday, July 15, 2009 6:29 PM
- Proposed as answer by Clayton Cobb Wednesday, July 15, 2009 7:34 PM
- Marked as answer by Dahey Wednesday, July 15, 2009 7:36 PM
Wednesday, July 15, 2009 6:23 PM
All replies
-
Sure, use rules.
On box B, create these rules that say
If A is not empty and B is not empty and A-B < 0, then set field C's value to 0
If A is not empty and B is not empty and A-B >= 0, then set field C's value to the formula A-B
There may be more you want to do, but those should work without the need for a button or default value.
SharePoint Architect || My Blog- Marked as answer by Dahey Wednesday, July 15, 2009 7:32 PM
- Unmarked as answer by Dahey Wednesday, July 15, 2009 7:36 PM
- Proposed as answer by Alec Pojidaev Wednesday, July 15, 2009 7:43 PM
- Marked as answer by Dahey Wednesday, October 5, 2011 9:55 PM
Wednesday, July 15, 2009 6:21 PM -
- Edited by Alec Pojidaev Wednesday, July 15, 2009 6:29 PM
- Proposed as answer by Clayton Cobb Wednesday, July 15, 2009 7:34 PM
- Marked as answer by Dahey Wednesday, July 15, 2009 7:36 PM
Wednesday, July 15, 2009 6:23 PM -
Alec, what does that mean? What is A>B in mathematical calculations?
SharePoint Architect || My BlogWednesday, July 15, 2009 6:29 PM -
The result of a>b is casted to the integer range [0:1] if logical opertation is part of algebraical formula.
http://alecpojidaev.wordpress.comWednesday, July 15, 2009 6:34 PM -
I don't understand how that works the way you wrote it. What you wrote is a simple multiplication of two things, one of which is not a value unless I'm missing something. Is there a function missing to do that check?
Edit: I guess not...how does that work without a function?
Still probably good to add a condition that they're both not blank since it defaults to 0 when one or both is blank.
SharePoint Architect || My Blog- Edited by Clayton Cobb Wednesday, July 15, 2009 6:58 PM
Wednesday, July 15, 2009 6:52 PM -
Understanding is overrated. Just accept the fact that it's working :)
http://alecpojidaev.wordpress.comWednesday, July 15, 2009 7:25 PM -
You know I can't leave it at that!! =P It definitely DOES work, though.
SharePoint Architect || My BlogWednesday, July 15, 2009 7:31 PM -
Very nice! Thank you!Wednesday, July 15, 2009 7:33 PM
-
Very nice! Thank you!
For what it's worth, Alec's is more efficient and concise. It can also be used as a default value to minimize logic and effort. I appreciate the answer credit on mine, but Alec's is much better as long as you include conditional logic.
SharePoint Architect || My BlogWednesday, July 15, 2009 7:35 PM -
Dahey , Don't encurage people to stop being nice please put your mark back to his answer :) His answer was correct and he tryed to be helpfull.
http://alecpojidaev.wordpress.comWednesday, July 15, 2009 7:40 PM -
Yeah, there can be more than one answer, so it doesn't have to be one or the other.
SharePoint Architect || My BlogWednesday, July 15, 2009 7:43 PM