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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Negative Numbers being treated as positive in calculations

Status
Not open for further replies.

beverlee

Instructor
Oct 8, 2002
61
US
I have a Fees Form (Fees1) with a Payment subform including two calculations in the form footer:

TotalAmountPaid=Sum([AMOUNTPAID])

Balance=IIf(IsNull([TotalAmountPaid]),[Forms]![frmclient]![fees1]!feeamount, [Forms]![frmclient]![fees1]!feeamount-[TotalAmountPaid])

It works fine most of the time. Every now and then it decides to start treating negative numbers as positive. If a payment adjustment needs to be made, the data is entered as a negative in the subform (amountpaid field) with either parentheses or a dash. 80% of the time the amount gets subtracted as intended. Sometimes, however, it adds the amount to the Balance instead of subtracting it.

Any thoughts? Thanks.
 
My guess off hand is that your else statement (feeamount - (totalamountpaid) is calculated "Wrong" because the only thing paid in the sum is adjustments. I.e your totalamountpaid is negative.

feeamount - -amount is mathmatically feeamount + amount

number - neg number = number + number.

I know I did not type this right but I think the problem happens only when the totalmountpaid is negative.

In other words you have not received any payments but have made an adjustment only.

Hope that is muddy enough for ya.



Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top