Calculations Issues

Adigga1

Registered User.
Local time
Today, 09:29
Joined
Oct 2, 2008
Messages
57
Hello Everyone,

I have an ergent issue with a totals column whereby the following occurs:

When my script perform a tally using currencies then placing a subtracted amount in a separate column, it produces inconsistent results.

Please refer to the attached image:

1. when my script tallies .79 it rounds to .80 (how to stop that?)
2. when whole numbers are entered, .80 appears out of no where (how to correct that?)
3. This in turn presents an incorrect total

Also, this is another example along the same lines of the issue at hand with code:

I have a Total charge field = $100.50
and i am looking to subtract = $50.50

And present the remaining total in field Surplus = $50.00

unfortunately the following code I have running is returning $100.50; $50.50 and $50.50 respectively. How do I stop the $.50 from carrying over?

Code:
Dim lngTotalCharge As Long
Dim sngECH As Long
If ECH.Text = "" Then
    sngECH = 0
 Else
    sngECH = CSng(ECH.Text)
End If
'delay
TotalCharge.SetFocus
Dim curTotalCharge As Currency
Dim strTotalCharge1 As String
strTotalCharge1 = TotalCharge.Text
If strTotalCharge1 = "" Then
   delay
End If
If strTotalCharge1 = "" Then
  ' delay
End If
If strTotalCharge1 = "" Then
 '  delay
End If
If strTotalCharge1 = "" Then
   'delay
End If
If strTotalCharge1 = "" Then
  ' delay
End If
If strTotalCharge1 = "" Then
 '  delay
End If
If strTotalCharge1 = "" Then
  ' delay
End If
curTotalCharge = CCur(strTotalCharge1)
txtPhysicians.SetFocus
txtPhysicians.Text = CStr(curTotalCharge - sngECH)
Else
txtPhysicians.SetFocus
txtPhysicians.Text = ""
ECH.SetFocus
ECH.Text = ""
TotalCharge.SetFocus
TotalCharge.Text = ""
End If

Thanks in advance for your patience and assistance in this matter

Regards,
A.....
 

Attachments

  • Calculations issue.JPG
    Calculations issue.JPG
    46.3 KB · Views: 147
Last edited:
It is a bit difficult to comment without seeing the code.

However note that the value in a currency field can include fractional cents. It just doesn't display them. You may need to round them before applying the values to other formulae.

Otherwise the fractional cents which rounded down separately may accumulate enough to round up as a total (or vice versa).
 

Users who are viewing this thread

Back
Top Bottom