Rounding Error?????????

GJT

Registered User.
Local time
Today, 21:14
Joined
Nov 5, 2002
Messages
116
I have come across a confounding problem....!!!

i have an invoice form that displays the sub-total / VAT / and Total fields. All of these are text boxes having the 'Fix' format type and 2 decimal places. Using the following values :

Sub total = 4547
VAT (@17.5%) = 795.725
this displays as 795.72 - when you put the cursor in the field it expands and displays 795.725.

The total field sums the VAT and the subtotal fields thus :
4547+795.725 = 5342.725 however this displays in the field as 5342.73 - when you put the cursor in the field it expands and displays 5342.725!

Why has the VAT field rounded down and the Total field roundedup? These totals must add up correctly!

Any ideas?
 
You're better off using currency types and a custom Round function
 
Unfortunately, using the currency type is not really an option, as this form is designed to work in all currencies not just
sterling.....
 
Public Function Round2CB(Value, Optional Precision As Variant) As Double

If IsNull(Value) Then Exit Function
If IsMissing(Precision) Then Precision = 2
Value = Fix(Value * 10 ^ Precision + 0.5 * Sgn(Value)) / 10 ^ Precision
Round2CB = Value

End Function
 
Can you make the data type a double?

I had a function calculating GPA and it was not rounding correctly because I was using a Single vs. a Double.
 

Users who are viewing this thread

Back
Top Bottom