dsum rounding - the bugger

CHAOSinACT

Registered User.
Local time
Today, 23:10
Joined
Mar 18, 2009
Messages
235
any one tell me why (and how to stop!!!) dsum from rounding up or down for currency?? seems like a silly thing to do...
 
What are the starting values and what datatype do you have them stored as and what do you see that the result SHOULD be?
 
lol fair questions!!
the table is in currency as are the fields on the subform. this is like a simple accounting system table to track expenditure variations. we have a ValueSubmitted Field with these numbers:

8950.00
4160.00
82560.00
43000.00
15950.00
-2686.40

the whole thing is processed by :

Private Sub Form_Current()
Dim longInvoicedVariances As Long
Dim longPendingVariances As Long

'load invoiced variances
If DSum("ValueApproved", "qryProjectVariancesInvoiced") <> 0 Then
longInvoicedVariances = DSum("ValueApproved", "qryProjectVariancesInvoiced")
Form_frmEditVariances.txtVariancesInvoiced.Value = longInvoicedVariances
Else
Form_frmEditVariances.txtVariancesInvoiced.Value = "0"
End If
'calc current total
Form_frmEditVariances.txtCurrentTotal.Value = Form_frmEditVariances.txtManualTotal.Value + longInvoicedVariances
'load pending invoices
If DSum("ValueSubmitted", "qryProjectVariancesNotInvoiced") <> 0 Then
longPendingVariances = DSum("ValueSubmitted", "qryProjectVariancesNotInvoiced")
Form_frmEditVariances.txtPendingVariations.Value = longPendingVariances
Else
Form_frmEditVariances.txtPendingVariations.Value = "0"
End If

'calc total in theory
Form_frmEditVariances.txtTotalInTheory.Value = Form_frmEditVariances.txtManualTotal.Value + longInvoicedVariances + longPendingVariances
End Sub
the "pending variaions" and i'm sure all though it wont show there yet, tallies those numbers to:

151,934.00
it should be
151,933.60

i personally would be ok with this but the accounts seem to think all the cents matter, doesn't access?? lol...
 
using a different data type for variable maybe???i'm guessing...
 
using a different data type for variable maybe???i'm guessing...

Well, there you go - you figured it out. I had missed that you had put it to a LONG INTEGER which doesn't include cents. I would use Currency for the datatype.
 
lol figured it out is lovely - i more candidly like to say "making it up as i go along" (i'm pretty good at that but still..) thanks!!!
 

Users who are viewing this thread

Back
Top Bottom