
Please help, Access 97 - Rounding currency in Report
Quote:
> Have developed Access 97 d'base.
> All values are formatted as currency,
> ie Table fields, action Query fields, Report controls are formatted as
> currency.
> Why do Report controls that rely on calculations show incorrect rounding in
> reports ?
> <snip>
> Profit $80.00 | $79.995
> ---------------------------------------------------------------------
> * How do I make the Profit display $79.99 on the Report ???
> ------------------------------------------------------
Looks to me like Access rounds correctly - you really don't want to
round at all, you want to truncate at two decimal places (as
mathematicians would say). I'm never gonna hire you as my
accountant...I want all those 0.5 of one cent! Assuming an even
distribution of digits in the third decimal position, truncation is
inherently less accurate than rounding. I don't know of any built-in
function that will do this.
But I love a challenge. We can come up with something: are you
willing to stick w/ 3 decimal places - ya know Access will allow you up
to 4 for Currency DataType. When you picked Currency DataType, Access
used the default of Auto for decimal places - go in and set all your
TextBoxes and table fields to 3 decimal places (or 4). Now, you're
gonna see all the places, all the time... you've been entering the third
decimal anyway, so ya might as well see it, except maybe on the report.
So, truncation:
Take one of your values from your table, let's call it Profit. Use the
Fix or Int function (I don't know how you'll wanna handle negative
numbers, but these give you two choices) to determine the fractional
component and truncate it, thusly:
varMyCurr = Profit
varFullFraction = varMyCurr - Fix(varMyCurr)
varTruncFraction = (Fix(varFullFraction * 100))/100
varMyTruncCurr = Fix(varMyCurr) + varTruncFraction
To truncate any value in your tables or calculations, set varMyCurr = to
that item, and call this code - you'll always wind up with
varMyTruncCurr, which is the truncated version of your original number.
Of course you can combine the above terms into one big step if you
wish...this is just my plodding sequence of steps to do the job.
Hope this gets the result you wanted.
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"
"What's so funny 'bout peace, love & understanding?"
- Nick Lowe