Hi,
I have 2 total fields - TotalDt and TotalCt, both numeric.
I would like to see if they balance. If not, a message is displayed to the user.
Initially I tried:
@If(TotalDt <> TotalCt;@Return(@Prompt([Ok];“Error”;“The Journal Transaction doesn’t balance.”));“”);
** THE ABOVE DIDN’T WORK.
My current formula:
@If(@Abs(TotalDt-TotalCt)>1;@Return(@Prompt([Ok];“Error”;“The Journal Transaction doesn’t balance.”));“”);
** THE ABOVE WORKS ONLY IF IT DIFFERS WITH MORE THAN 1.
How do I fix this?
Subject: Compare Number Fields
There is nothing wrong with your first formula. I suspect that the problem is due to where you have put the code. Can you explain where you have put this line of code ? How is it invoked ?
Subject: RE: Compare Number Fields
The formula is in a button.
Subject: RE: Compare Number Fields
I created a form with the 2 numeric fields, pasted your first formula into a button and it works fine ! Are you sure the 2 fields are numeric ? Are you sure they contain the same contents ?
Subject: floating point error
Did you try the old rounding trick? You cannot compare two floating point numbers for equivalence in any binary computer and expect them to match unless they are powers/logarithms of two. You need to round both numbers to an appropriate confidence margin and compare them then.