Round as calculator

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

I asked this question before and I did get responses but
they did not solve the problem. The problem is, when I use
Excel or Access to total dollars, I cannot get Access to
match a calculator. Rounding changes the total but only by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so numbers
on each page on a calculator to match either Excel's or
Access'total. The reason it must match the calculator is
money is transfered from one entity to another. As I
calculate the totals using software and the other entity
checks my work using a calculator, the totals do not match
and are off each month by cents. Of course this causes
accounting problems that cannot be reconciled. Currently,
to make it match, I add up the totals using a calculator
and type them on the reports generated by Access. Does
anyone have any ideas?

Dennis
 
Hi Dennis

just a thought ... i read somewhere recently that if you use the "currency"
data type in the underlying tables in access they should "round" correctly.
Be warned, i haven't tested this so before you make any changes to your
database PLEASE back it up.

Cheers
JulieD
 
I think we went 'round with this before. <pun intended>

If the line items are the result of a calculation, you must round each value
internally and stuff it into a fixed point data type such as Currency or
Decimal. Then, add the fixed point results.

In the classic Northwind example, each line item is calculated as:

[UnitPrice]*[Quantity]*(1-[Discount])

Because Discount is a fraction, you sometimes end up with odd fractions of
cents. For example, a unit price of $35.10, quantity 35, and discount 25%
yields $921.37500 - and that odd half-cent has the potential to make your
total wrong. In the Access 2002 version of Northwind, the underlying query
uses a calculation that truncates the odd fractions of cents:

CCur([Order Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100

Dividing by 100 and then converting to Currency yields $9.2137 (because
Currency has only 4 fixed decimal places). The final multiply by 100 yields
$921.3700 - no fractions.

You can also round by using a formula like:

CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1-[Discount]),2))

This yields $921.3800 - again, no fractions.

To get the correct total, you must use one of the above expressions in a
SUM. If you want to round, then use the second expression and use:

=Sum(CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1-[Discount]),2)))

... in your report or group footer.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Two suggestions.

One-If the field is not currency type then change it to currency type (accurate
to four decimals).

Two-Round BEFORE summing, if you aren't already doing so. Sum(Round(...)) vice Round(Sum(...))

Are your individual values exactly equal to dollars and cents with no partial
pennies? If you have partial cents and truncate them versus round them, you
will get different totals. 1.026 rounds to 1.03; while you might want that to
truncate to 1.02.

You can sum truncated values by doing something like the following.
Sum(Clng(SomeField*100))/100
 
Yes Sir we did go around with this problem before.:) I
have been working on this problem every spare monent
since. I have used the following round on every expression
and code that make a calculation. Maybe that is the
problem? Maybe I should only use the round on some
expressions and not all? The following are samples of
expressions used:

Rounded Expressions in one query:
Sum Of Pay: Round([AccentqryD]![Sum Of Pay],2)

Direct Pay $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Pay]*0.85,2),Round([Sum Of Pay]*0,2)))

Indirect Pay: Sum(IIf([Cost Center]="13601",Round([Sum Of
Pay]*0.15,2),Round([Sum Of Pay],2)))

Sum of Reg $: Round([AccentqryD]![Sum of Reg $],2)

Direct Reg $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Reg $]*0.85,2),Round([Sum Of Reg $]*0,2)))

Indirect Reg $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Reg $]*0.15,2),Round([Sum Of Reg $],2)))

Sum Of Bnft $: Round([AccentqryD]![Sum Of Bnft Hours],2)

Direct Bnft $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Bnft $]*0.85,2),Round([Sum Of Bnft $]*0,2)))

Indirect Bnft $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Bnft $]*0.15,2),Round([Sum Of Bnft $],2)))

Sum Of Adjust $: Round([AccentqryD]![Sum Of Adjust $],2)

Direct Adjust $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Adjust $]*0.85,2),Round([Sum Of Adjust $]*0,2)))

Indirect Adjust $: Sum(IIf([Cost Center]="13601",Round
([Sum Of Adjust $]*0.15,2),Round([Sum Of Adjust $],2)))

Expressions Not Rounded:
Indirect Hours: Sum(IIf([Cost Center]="13601",[Sum Of Reg
Hours ]*0.15,[Sum Of Reg Hours]*1))

Direct Hours: Sum(IIf([Cost Center]="13601",[Sum Of Reg
Hours ]*0.85,[Sum Of Reg Hours]*0))

Rounded Expressions in Reports:
This expression in report that sums all to a grand total:
=Sum(Round([Accentqry]![Sum Of Pay],2))

This expression in another report that gets the same
answer using a little different method:

=Sum(Round(([Employees].[Reg Hours]+[Employees].[Bnft
Hours])*([Employees].[Rate])+([Employees].[Adjust $]),2))

Code Expressions:
Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

I hope this is enough information to give you an idea of
where I have gone wrong.

Thank you,

Dennis

-----Original Message-----
I think we went 'round with this before. <pun intended>

If the line items are the result of a calculation, you must round each value
internally and stuff it into a fixed point data type such as Currency or
Decimal. Then, add the fixed point results.

In the classic Northwind example, each line item is calculated as:

[UnitPrice]*[Quantity]*(1-[Discount])

Because Discount is a fraction, you sometimes end up with odd fractions of
cents. For example, a unit price of $35.10, quantity 35, and discount 25%
yields $921.37500 - and that odd half-cent has the potential to make your
total wrong. In the Access 2002 version of Northwind, the underlying query
uses a calculation that truncates the odd fractions of cents:

CCur([Order Details].UnitPrice*[Quantity]*(1- [Discount])/100)*100

Dividing by 100 and then converting to Currency yields $9.2137 (because
Currency has only 4 fixed decimal places). The final multiply by 100 yields
$921.3700 - no fractions.

You can also round by using a formula like:

CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1- [Discount]),2))

This yields $921.3800 - again, no fractions.

To get the correct total, you must use one of the above expressions in a
SUM. If you want to round, then use the second expression and use:

=Sum(CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1- [Discount]),2)))

... in your report or group footer.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
I asked this question before and I did get responses but
they did not solve the problem. The problem is, when I use
Excel or Access to total dollars, I cannot get Access to
match a calculator. Rounding changes the total but only by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so numbers
on each page on a calculator to match either Excel's or
Access'total. The reason it must match the calculator is
money is transfered from one entity to another. As I
calculate the totals using software and the other entity
checks my work using a calculator, the totals do not match
and are off each month by cents. Of course this causes
accounting problems that cannot be reconciled. Currently,
to make it match, I add up the totals using a calculator
and type them on the reports generated by Access. Does
anyone have any ideas?

Dennis


.
 
Steve,

Below are three samples of different pages and comparison
to the calculator.

$182.32
$71.51
$115.69
$94.33
$80.81
$129.45
$67.18
$113.49
$74.79
$73.23
$144.74
$68.99
$148.93
$72.53
$96.14
$124.89
$86.70
$155.39
$115.39
$9.26
$67.07
$43.54
$105.04
$78.53
$11.46
$45.09
$0.00
$140.34
$70.07
$115.23
$75.53
$90.49
$0.00
$94.48
$48.63
Access Page Total $3,011.25
Calculator Total $3,011.26 +1

$110.24
$84.76
$147.66
$125.90
$96.05
$9.61
$0.00
$70.69
$113.28
$97.60
$0.00
$109.32
$183.43
$78.03
$70.92
$77.90
$0.00
$102.91
$118.49
$76.39
$117.96
$77.32
$65.66
$0.00
$142.80
$39.33
$129.08
$99.83
$0.00
$88.07
$100.82
$145.95
$106.32
$35.63
$87.11
$205.04
$187.01
$71.45
$89.20
Access Page Total $3,461.72
Calculator Total $3,461.76 +4
$212.28
$70.99
$178.22
$59.15
$112.67
$45.83
$135.68
$64.64
$118.87
$109.33
$111.35
T$49.12
$66.14
$80.69
$122.23
$62.12
$115.62
$114.16
$0.00
$142.86
$124.28
$73.25
$131.45
$115.10
$91.34
$123.97

$82.87
$76.76
$107.74
$114.59
$165.06
$128.85
$55.72
$118.32
$98.49
$74.84
$81.61
$57.69
Access Page Total $3,793.88
Calculator Total $3,793.88 +- 0

I hope this is enough data.
Thanks,

Dennis
 
OK. So "internally" some of the numbers in the column have fractions that
are causing the grand total to be off. What is the exact expression you're
using to display the individual column numbers. What is the expression to
calculate the total?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
It's not possible to figure out this specific problem from the list below.
See my reply to your reply to Steve.

Just a couple of notes:

1) Why not round all expressions?

2) Why are you making expressions more complex than necessary? Example:

Direct Pay $: Sum(IIf([Cost Center]="13601",
Round([Sum Of Pay]*0.85,2),Round([Sum Of Pay]*0,2)))

Umm. Anything times zero is zero. Why not use:

Direct Pay $: Sum(IIf([Cost Center]="13601",
Round([Sum Of Pay]*0.85,2), 0))



--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Dennis said:
Yes Sir we did go around with this problem before.:) I
have been working on this problem every spare monent
since. I have used the following round on every expression
and code that make a calculation. Maybe that is the
problem? Maybe I should only use the round on some
expressions and not all? The following are samples of
expressions used:

Rounded Expressions in one query:
Sum Of Pay: Round([AccentqryD]![Sum Of Pay],2)

Direct Pay $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Pay]*0.85,2),Round([Sum Of Pay]*0,2)))

Indirect Pay: Sum(IIf([Cost Center]="13601",Round([Sum Of
Pay]*0.15,2),Round([Sum Of Pay],2)))

Sum of Reg $: Round([AccentqryD]![Sum of Reg $],2)

Direct Reg $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Reg $]*0.85,2),Round([Sum Of Reg $]*0,2)))

Indirect Reg $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Reg $]*0.15,2),Round([Sum Of Reg $],2)))

Sum Of Bnft $: Round([AccentqryD]![Sum Of Bnft Hours],2)

Direct Bnft $: Sum(IIf([Cost Center]="13601",Round([Sum Of
Bnft $]*0.85,2),Round([Sum Of Bnft $]*0,2)))

Indirect Bnft $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Bnft $]*0.15,2),Round([Sum Of Bnft $],2)))

Sum Of Adjust $: Round([AccentqryD]![Sum Of Adjust $],2)

Direct Adjust $: Sum(IIf([Cost Center]="13601",Round([Sum
Of Adjust $]*0.85,2),Round([Sum Of Adjust $]*0,2)))

Indirect Adjust $: Sum(IIf([Cost Center]="13601",Round
([Sum Of Adjust $]*0.15,2),Round([Sum Of Adjust $],2)))

Expressions Not Rounded:
Indirect Hours: Sum(IIf([Cost Center]="13601",[Sum Of Reg
Hours ]*0.15,[Sum Of Reg Hours]*1))

Direct Hours: Sum(IIf([Cost Center]="13601",[Sum Of Reg
Hours ]*0.85,[Sum Of Reg Hours]*0))

Rounded Expressions in Reports:
This expression in report that sums all to a grand total:
=Sum(Round([Accentqry]![Sum Of Pay],2))

This expression in another report that gets the same
answer using a little different method:

=Sum(Round(([Employees].[Reg Hours]+[Employees].[Bnft
Hours])*([Employees].[Rate])+([Employees].[Adjust $]),2))

Code Expressions:
Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

I hope this is enough information to give you an idea of
where I have gone wrong.

Thank you,

Dennis

-----Original Message-----
I think we went 'round with this before. <pun intended>

If the line items are the result of a calculation, you must round each value
internally and stuff it into a fixed point data type such as Currency or
Decimal. Then, add the fixed point results.

In the classic Northwind example, each line item is calculated as:

[UnitPrice]*[Quantity]*(1-[Discount])

Because Discount is a fraction, you sometimes end up with odd fractions of
cents. For example, a unit price of $35.10, quantity 35, and discount 25%
yields $921.37500 - and that odd half-cent has the potential to make your
total wrong. In the Access 2002 version of Northwind, the underlying query
uses a calculation that truncates the odd fractions of cents:

CCur([Order Details].UnitPrice*[Quantity]*(1- [Discount])/100)*100

Dividing by 100 and then converting to Currency yields $9.2137 (because
Currency has only 4 fixed decimal places). The final multiply by 100 yields
$921.3700 - no fractions.

You can also round by using a formula like:

CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1- [Discount]),2))

This yields $921.3800 - again, no fractions.

To get the correct total, you must use one of the above expressions in a
SUM. If you want to round, then use the second expression and use:

=Sum(CCur(Round([Order Details].[UnitPrice]*[Quantity]*(1- [Discount]),2)))

... in your report or group footer.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
I asked this question before and I did get responses but
they did not solve the problem. The problem is, when I use
Excel or Access to total dollars, I cannot get Access to
match a calculator. Rounding changes the total but only by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so numbers
on each page on a calculator to match either Excel's or
Access'total. The reason it must match the calculator is
money is transfered from one entity to another. As I
calculate the totals using software and the other entity
checks my work using a calculator, the totals do not match
and are off each month by cents. Of course this causes
accounting problems that cannot be reconciled. Currently,
to make it match, I add up the totals using a calculator
and type them on the reports generated by Access. Does
anyone have any ideas?

Dennis


.
 
John,
using to display the individual column numbers.<<

=Round(([Reg $]+[Bnft $]+[Adjust $]),2)
I also rounded per your suggestion Reg $, Bnft $ and
Adjust $ which are fields that this expression addresses.
This made the Page total $3,011.24 looking for $3,011.26.

I use a text box named PageTotal and code to give a page
total. Code as follows:

Option Explicit 'Optional, but recommended for
every module.
Dim curTotal As Currency 'Variable to sum [Amount] over
a page.

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
Me.PageTotal = curTotal
End Sub

Private Sub PageHeader_Format(Cancel As Integer,
FormatCount As Integer)
curTotal = 0 'Reset the sum to zero each new
Page.
End Sub

"Code from Alan Browne's Site"

Thanks,

Dennis
 
What is Me.Workers_Pay? Is that the same as =Round(([Reg $]+[Bnft
$]+[Adjust $]),2) ? If you're not summing the same value you're displaying,
then who knows where the problem lies? Also, in your code, you're rounding
the wrong thing. Try this:

curTotal = curTotal + Round(Nz(Me.Workers_Pay, 0), 2)

You need to round the individual values, not the value after you've added it
to the cumulative total.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Dennis said:
John,
using to display the individual column numbers.<<

=Round(([Reg $]+[Bnft $]+[Adjust $]),2)
I also rounded per your suggestion Reg $, Bnft $ and
Adjust $ which are fields that this expression addresses.
This made the Page total $3,011.24 looking for $3,011.26.

I use a text box named PageTotal and code to give a page
total. Code as follows:

Option Explicit 'Optional, but recommended for
every module.
Dim curTotal As Currency 'Variable to sum [Amount] over
a page.

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
Me.PageTotal = curTotal
End Sub

Private Sub PageHeader_Format(Cancel As Integer,
FormatCount As Integer)
curTotal = 0 'Reset the sum to zero each new
Page.
End Sub

"Code from Alan Browne's Site"

Thanks,

Dennis
-----Original Message-----
OK. So "internally" some of the numbers in the column have fractions that
are causing the grand total to be off. What is the exact expression you're
using to display the individual column numbers. What is the expression to
calculate the total?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)



.
 
Jhon,

I have tried to round, many different ways and now I have
tried to trim decimals. None of the things I have tried
match the calculations of the calculator. Maybe it is not
a rounding problem? Here is the logic I am using. I have a
table (Employees) that data is entered. I have fields used
in my expressions such as Regular hours worked (Reg Hours)
hours and 100th's of hours for minutes, wage paid (Wage),
Holiday hours (Bnft Hours) and Adjustment dollars (Adjust
$). Adjust $ and Wage are both formatted as currency. Bnft
Hours and Reg Hours are Double, general numbers with 2
decimal places.

The math in my report is pretty straight forward.
Reg $:=Round(([Rate]*[Reg Hours]),2)
Bnft $:=Round(([Rate]*[Bnft Hours]),2)
Adjust $ (Field in Employees table)

Workers_Pay:=Round(([Reg $]+[Bnft $]+[Adjust $]),2) This
gives the total pay given to each worker.

I have also removed the Round in the above expressions to
no avail.

I sum the report using the following expression: =Sum(Round
(([Employees].[Reg Hours]+[Employees].[Bnft Hours])*
([Employees].[Rate])+([Employees].[Adjust $]),2))

The Calculator gives a result of $33,601.78 and the Report
returns a total of $33,601.52. I also have page totals
that in some cases matches the calculator exactly and
other pages are off by 4 cents a total of 22 cents for all
pages. The Calculator is always more $$ than the Report.
What do you think?

Dennis
-----Original Message-----
What is Me.Workers_Pay? Is that the same as =Round(([Reg $]+[Bnft
$]+[Adjust $]),2) ? If you're not summing the same value you're displaying,
then who knows where the problem lies? Also, in your code, you're rounding
the wrong thing. Try this:

curTotal = curTotal + Round(Nz(Me.Workers_Pay, 0), 2)

You need to round the individual values, not the value after you've added it
to the cumulative total.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
John,

What is the exact expression you're
using to display the individual column numbers.<<

=Round(([Reg $]+[Bnft $]+[Adjust $]),2)
I also rounded per your suggestion Reg $, Bnft $ and
Adjust $ which are fields that this expression addresses.
This made the Page total $3,011.24 looking for $3,011.26.
What is the expression to calculate the total?<<

I use a text box named PageTotal and code to give a page
total. Code as follows:

Option Explicit 'Optional, but recommended for
every module.
Dim curTotal As Currency 'Variable to sum [Amount] over
a page.

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
Me.PageTotal = curTotal
End Sub

Private Sub PageHeader_Format(Cancel As Integer,
FormatCount As Integer)
curTotal = 0 'Reset the sum to zero each new
Page.
End Sub

"Code from Alan Browne's Site"

Thanks,

Dennis
-----Original Message-----
OK. So "internally" some of the numbers in the column have fractions that
are causing the grand total to be off. What is the
exact
expression you're
using to display the individual column numbers. What
is
the expression to
calculate the total?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Steve,

Below are three samples of different pages and comparison
to the calculator.

$182.32
$71.51
$115.69
$94.33
$80.81
$129.45
$67.18
$113.49
$74.79
$73.23
$144.74
$68.99
$148.93
$72.53
$96.14
$124.89
$86.70
$155.39
$115.39
$9.26
$67.07
$43.54
$105.04
$78.53
$11.46
$45.09
$0.00
$140.34
$70.07
$115.23
$75.53
$90.49
$0.00
$94.48
$48.63
Access Page Total $3,011.25
Calculator Total $3,011.26 +1

$110.24
$84.76
$147.66
$125.90
$96.05
$9.61
$0.00
$70.69
$113.28
$97.60
$0.00
$109.32
$183.43
$78.03
$70.92
$77.90
$0.00
$102.91
$118.49
$76.39
$117.96
$77.32
$65.66
$0.00
$142.80
$39.33
$129.08
$99.83
$0.00
$88.07
$100.82
$145.95
$106.32
$35.63
$87.11
$205.04
$187.01
$71.45
$89.20
Access Page Total $3,461.72
Calculator Total $3,461.76 +4
$212.28
$70.99
$178.22
$59.15
$112.67
$45.83
$135.68
$64.64
$118.87
$109.33
$111.35
T$49.12
$66.14
$80.69
$122.23
$62.12
$115.62
$114.16
$0.00
$142.86
$124.28
$73.25
$131.45
$115.10
$91.34
$123.97

$82.87
$76.76
$107.74
$114.59
$165.06
$128.85
$55.72
$118.32
$98.49
$74.84
$81.61
$57.69
Access Page Total $3,793.88
Calculator Total $3,793.88 +- 0

I hope this is enough data.
Thanks,

Dennis



-----Original Message-----
Dennis,

Can you please supply an example of the 35 numbers you
are adding?

--
Steve Schapel, Microsoft Access MVP


Dennis wrote:
I asked this question before and I did get responses
but
they did not solve the problem. The problem is,
when
I
use
Excel or Access to total dollars, I cannot get Access
to
match a calculator. Rounding changes the total but only
by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so
numbers
on each page on a calculator to match either
Excel's
or
Access'total. The reason it must match the calculator
is
money is transfered from one entity to another. As I
calculate the totals using software and the other
entity
checks my work using a calculator, the totals do not
match
and are off each month by cents. Of course this causes
accounting problems that cannot be reconciled.
Currently,
to make it match, I add up the totals using a
calculator
and type them on the reports generated by Access. Does
anyone have any ideas?

Dennis
.



.


.
 
Did you fix the page addition code as I recommended previously? That should
fix your page totals. Your grand total is also wrong. It should be:

=Sum(CCur(Round(([Employees].[Reg Hours]+[Employees].[Bnft Hours])*
[Employees].[Rate],2))+([Employees].[Adjust $]))

Basically, you should Round only when you're multiplying hours times a rate.
Once you have rounded a value, it does no good to round it again. Round all
your basic Hours*Rate values and convert to Currency, and you should be OK.

Maybe you should start over and remove ALL Round function calls. Then go
back through it all and CCur(Round( <any hours> * <any rate> ), 2)

The trick is to get rid of fractions of cents the instant they might occur -
any time you multiply a fraction of hours times a fraction of dollars.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Dennis said:
Jhon,

I have tried to round, many different ways and now I have
tried to trim decimals. None of the things I have tried
match the calculations of the calculator. Maybe it is not
a rounding problem? Here is the logic I am using. I have a
table (Employees) that data is entered. I have fields used
in my expressions such as Regular hours worked (Reg Hours)
hours and 100th's of hours for minutes, wage paid (Wage),
Holiday hours (Bnft Hours) and Adjustment dollars (Adjust
$). Adjust $ and Wage are both formatted as currency. Bnft
Hours and Reg Hours are Double, general numbers with 2
decimal places.

The math in my report is pretty straight forward.
Reg $:=Round(([Rate]*[Reg Hours]),2)
Bnft $:=Round(([Rate]*[Bnft Hours]),2)
Adjust $ (Field in Employees table)

Workers_Pay:=Round(([Reg $]+[Bnft $]+[Adjust $]),2) This
gives the total pay given to each worker.

I have also removed the Round in the above expressions to
no avail.

I sum the report using the following expression: =Sum(Round
(([Employees].[Reg Hours]+[Employees].[Bnft Hours])*
([Employees].[Rate])+([Employees].[Adjust $]),2))

The Calculator gives a result of $33,601.78 and the Report
returns a total of $33,601.52. I also have page totals
that in some cases matches the calculator exactly and
other pages are off by 4 cents a total of 22 cents for all
pages. The Calculator is always more $$ than the Report.
What do you think?

Dennis
-----Original Message-----
What is Me.Workers_Pay? Is that the same as =Round(([Reg $]+[Bnft
$]+[Adjust $]),2) ? If you're not summing the same value you're displaying,
then who knows where the problem lies? Also, in your code, you're rounding
the wrong thing. Try this:

curTotal = curTotal + Round(Nz(Me.Workers_Pay, 0), 2)

You need to round the individual values, not the value after you've added it
to the cumulative total.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
John,

What is the exact expression you're
using to display the individual column numbers.<<

=Round(([Reg $]+[Bnft $]+[Adjust $]),2)
I also rounded per your suggestion Reg $, Bnft $ and
Adjust $ which are fields that this expression addresses.
This made the Page total $3,011.24 looking for $3,011.26.

What is the expression to calculate the total?<<

I use a text box named PageTotal and code to give a page
total. Code as follows:

Option Explicit 'Optional, but recommended for
every module.
Dim curTotal As Currency 'Variable to sum [Amount] over
a page.

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
Me.PageTotal = curTotal
End Sub

Private Sub PageHeader_Format(Cancel As Integer,
FormatCount As Integer)
curTotal = 0 'Reset the sum to zero each new
Page.
End Sub

"Code from Alan Browne's Site"

Thanks,

Dennis

-----Original Message-----
OK. So "internally" some of the numbers in the column
have fractions that
are causing the grand total to be off. What is the exact
expression you're
using to display the individual column numbers. What is
the expression to
calculate the total?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
message
Steve,

Below are three samples of different pages and
comparison
to the calculator.

$182.32
$71.51
$115.69
$94.33
$80.81
$129.45
$67.18
$113.49
$74.79
$73.23
$144.74
$68.99
$148.93
$72.53
$96.14
$124.89
$86.70
$155.39
$115.39
$9.26
$67.07
$43.54
$105.04
$78.53
$11.46
$45.09
$0.00
$140.34
$70.07
$115.23
$75.53
$90.49
$0.00
$94.48
$48.63
Access Page Total $3,011.25
Calculator Total $3,011.26 +1

$110.24
$84.76
$147.66
$125.90
$96.05
$9.61
$0.00
$70.69
$113.28
$97.60
$0.00
$109.32
$183.43
$78.03
$70.92
$77.90
$0.00
$102.91
$118.49
$76.39
$117.96
$77.32
$65.66
$0.00
$142.80
$39.33
$129.08
$99.83
$0.00
$88.07
$100.82
$145.95
$106.32
$35.63
$87.11
$205.04
$187.01
$71.45
$89.20
Access Page Total $3,461.72
Calculator Total $3,461.76 +4
$212.28
$70.99
$178.22
$59.15
$112.67
$45.83
$135.68
$64.64
$118.87
$109.33
$111.35
T$49.12
$66.14
$80.69
$122.23
$62.12
$115.62
$114.16
$0.00
$142.86
$124.28
$73.25
$131.45
$115.10
$91.34
$123.97

$82.87
$76.76
$107.74
$114.59
$165.06
$128.85
$55.72
$118.32
$98.49
$74.84
$81.61
$57.69
Access Page Total $3,793.88
Calculator Total $3,793.88 +- 0

I hope this is enough data.
Thanks,

Dennis



-----Original Message-----
Dennis,

Can you please supply an example of the 35 numbers you
are adding?

--
Steve Schapel, Microsoft Access MVP


Dennis wrote:
I asked this question before and I did get responses
but
they did not solve the problem. The problem is, when
I
use
Excel or Access to total dollars, I cannot get Access
to
match a calculator. Rounding changes the total but
only
by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so
numbers
on each page on a calculator to match either Excel's
or
Access'total. The reason it must match the calculator
is
money is transfered from one entity to another. As I
calculate the totals using software and the other
entity
checks my work using a calculator, the totals do not
match
and are off each month by cents. Of course this
causes
accounting problems that cannot be reconciled.
Currently,
to make it match, I add up the totals using a
calculator
and type them on the reports generated by Access.
Does
anyone have any ideas?

Dennis
.



.


.
 
I have fields used
in my expressions such as Regular hours worked (Reg Hours)
hours and 100th's of hours for minutes

So... you have 3.25 as three hours and 25 minutes? If so - THAT'S the
problem! Access number fields are base 10, not sexegesimal (and I
don't know of any base 60 computers though I'm sure it can be done).

3.25 + 3.25 + 3.25 is going to come out 9.75, not 10.15.

Am I misunderstanding? Do you have code that will correctly treat 3.30
as three and a half hours?
 
John,
To address your previous post: My time clock calculates
time in 100th. That means that .50 on the clock = .30
miniutes. Does that need to have any code to convert? I
thought that part was clean?

Second Post:

Yes I fixed the page addition code but the page totals do
not match the calculators. I will rework the expressions
and code. Will let you know what happens.

Dennis
-----Original Message-----
Did you fix the page addition code as I recommended previously? That should
fix your page totals. Your grand total is also wrong. It should be:

=Sum(CCur(Round(([Employees].[Reg Hours]+[Employees]. [Bnft Hours])*
[Employees].[Rate],2))+([Employees].[Adjust $]))

Basically, you should Round only when you're multiplying hours times a rate.
Once you have rounded a value, it does no good to round it again. Round all
your basic Hours*Rate values and convert to Currency, and you should be OK.

Maybe you should start over and remove ALL Round function calls. Then go
back through it all and CCur(Round( <any hours> * <any rate> ), 2)

The trick is to get rid of fractions of cents the instant they might occur -
any time you multiply a fraction of hours times a fraction of dollars.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Jhon,

I have tried to round, many different ways and now I have
tried to trim decimals. None of the things I have tried
match the calculations of the calculator. Maybe it is not
a rounding problem? Here is the logic I am using. I have a
table (Employees) that data is entered. I have fields used
in my expressions such as Regular hours worked (Reg Hours)
hours and 100th's of hours for minutes, wage paid (Wage),
Holiday hours (Bnft Hours) and Adjustment dollars (Adjust
$). Adjust $ and Wage are both formatted as currency. Bnft
Hours and Reg Hours are Double, general numbers with 2
decimal places.

The math in my report is pretty straight forward.
Reg $:=Round(([Rate]*[Reg Hours]),2)
Bnft $:=Round(([Rate]*[Bnft Hours]),2)
Adjust $ (Field in Employees table)

Workers_Pay:=Round(([Reg $]+[Bnft $]+[Adjust $]),2) This
gives the total pay given to each worker.

I have also removed the Round in the above expressions to
no avail.

I sum the report using the following expression: =Sum (Round
(([Employees].[Reg Hours]+[Employees].[Bnft Hours])*
([Employees].[Rate])+([Employees].[Adjust $]),2))

The Calculator gives a result of $33,601.78 and the Report
returns a total of $33,601.52. I also have page totals
that in some cases matches the calculator exactly and
other pages are off by 4 cents a total of 22 cents for all
pages. The Calculator is always more $$ than the Report.
What do you think?

Dennis
-----Original Message-----
What is Me.Workers_Pay? Is that the same as =Round
(([Reg
$]+[Bnft
$]+[Adjust $]),2) ? If you're not summing the same
value
you're displaying,
then who knows where the problem lies? Also, in your code, you're rounding
the wrong thing. Try this:

curTotal = curTotal + Round(Nz(Me.Workers_Pay, 0), 2)

You need to round the individual values, not the value after you've added it
to the cumulative total.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
John,

What is the exact expression you're
using to display the individual column numbers.<<

=Round(([Reg $]+[Bnft $]+[Adjust $]),2)
I also rounded per your suggestion Reg $, Bnft $ and
Adjust $ which are fields that this expression addresses.
This made the Page total $3,011.24 looking for $3,011.26.

What is the expression to calculate the total?<<

I use a text box named PageTotal and code to give a page
total. Code as follows:

Option Explicit 'Optional, but recommended for
every module.
Dim curTotal As Currency 'Variable to sum [Amount] over
a page.

Private Sub Detail_Print(Cancel As Integer,
PrintCount
As
Integer)
If PrintCount = 1 Then curTotal = Round(curTotal + Nz
(Me.Workers_Pay, 0), 2)
End Sub

Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
Me.PageTotal = curTotal
End Sub

Private Sub PageHeader_Format(Cancel As Integer,
FormatCount As Integer)
curTotal = 0 'Reset the sum to zero each new
Page.
End Sub

"Code from Alan Browne's Site"

Thanks,

Dennis

-----Original Message-----
OK. So "internally" some of the numbers in the column
have fractions that
are causing the grand total to be off. What is the exact
expression you're
using to display the individual column numbers.
What
is
the expression to
calculate the total?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
message
Steve,

Below are three samples of different pages and
comparison
to the calculator.

$182.32
$71.51
$115.69
$94.33
$80.81
$129.45
$67.18
$113.49
$74.79
$73.23
$144.74
$68.99
$148.93
$72.53
$96.14
$124.89
$86.70
$155.39
$115.39
$9.26
$67.07
$43.54
$105.04
$78.53
$11.46
$45.09
$0.00
$140.34
$70.07
$115.23
$75.53
$90.49
$0.00
$94.48
$48.63
Access Page Total $3,011.25
Calculator Total $3,011.26 +1

$110.24
$84.76
$147.66
$125.90
$96.05
$9.61
$0.00
$70.69
$113.28
$97.60
$0.00
$109.32
$183.43
$78.03
$70.92
$77.90
$0.00
$102.91
$118.49
$76.39
$117.96
$77.32
$65.66
$0.00
$142.80
$39.33
$129.08
$99.83
$0.00
$88.07
$100.82
$145.95
$106.32
$35.63
$87.11
$205.04
$187.01
$71.45
$89.20
Access Page Total $3,461.72
Calculator Total $3,461.76 +4
$212.28
$70.99
$178.22
$59.15
$112.67
$45.83
$135.68
$64.64
$118.87
$109.33
$111.35
T$49.12
$66.14
$80.69
$122.23
$62.12
$115.62
$114.16
$0.00
$142.86
$124.28
$73.25
$131.45
$115.10
$91.34
$123.97

$82.87
$76.76
$107.74
$114.59
$165.06
$128.85
$55.72
$118.32
$98.49
$74.84
$81.61
$57.69
Access Page Total $3,793.88
Calculator Total $3,793.88 +- 0

I hope this is enough data.
Thanks,

Dennis



-----Original Message-----
Dennis,

Can you please supply an example of the 35
numbers
you
are adding?

--
Steve Schapel, Microsoft Access MVP


Dennis wrote:
I asked this question before and I did get responses
but
they did not solve the problem. The problem is, when
I
use
Excel or Access to total dollars, I cannot get Access
to
match a calculator. Rounding changes the total but
only
by
one or two cents not the 22 cent difference.

When I use a page total, I cannot add the 35 or so
numbers
on each page on a calculator to match either Excel's
or
Access'total. The reason it must match the calculator
is
money is transfered from one entity to another. As I
calculate the totals using software and the other
entity
checks my work using a calculator, the totals
do
not
match
and are off each month by cents. Of course this
causes
accounting problems that cannot be reconciled.
Currently,
to make it match, I add up the totals using a
calculator
and type them on the reports generated by Access.
Does
anyone have any ideas?

Dennis
.



.



.


.
 
Back
Top