Please help, Access 97 - Rounding currency in Report 
Author Message
 Please help, Access 97 - Rounding currency in Report

Any insight will be greatly appreciated:

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 ?

ie Calculated controls in Reports will use ALL the decimal places available
in making the calculation then display to 2 decimal places accuracy, thereby
showing incorrect results on reports.

eg, a typical report:

 VALUES DISPLAYED IN REPORT        |   ACTUAL VALUES
---------------------------------------------------------------------
Revenue       $100.00                                 |   $100.000
Expenses       $20.01                                  |    $20.005
--------------------------------------------|------------------------
Profit             $80.00                                  |    $79.995
---------------------------------------------------------------------

* How do I make the Profit display $79.99 on the Report ???
------------------------------------------------------

I cannot find an inbuilt rounding function to store calculated values to 2
decimal places.

* Do I have to write my own custom rounding function ?
* Has anyone got such a rounding function they can share?
* Or am I simply ignorant of some important property that will solve this
problem?

Any assistance will be greatly appreciated.

Tom.



Sun, 30 Dec 2001 03:00:00 GMT  
 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



Sun, 30 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Rounding Currency In Reports - Help !!

2. VB/Access 97 report help please

3. round up currencies in Access

4. ROUND function missing in Access 97???

5. Access 97 and converting to integer (rounding function)....

6. Rounding to two decimal places (Access 97)

7. Exporting a report to MS Word 97 problem, Please Help

8. Help Please - MScomm in Access 97

9. Access 97 Stabilty. Please Help

10. - Access 97 textbox problems, please help -

11. Please help - overflow error using Access 97 database

12. vb6 & passworded access 97 dataase(s) [please help]

 

 
Powered by phpBB® Forum Software