[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Simple Forumula is returning 3.63797880709171E-12

Posted on 2006-06-01
Medium Priority
Last Modified: 2006-11-18

I am trying to write a qry that does a simple minus calculation.  To explain I have created two other qry's that sum two tables. These two qry's are called

qryTotalPayments = sums each clients total payments $
qryTotalOrders = sums each clients total orders $

I have checked the values in both these qry's and they look correct.  The qryOutstandingAmount that I am having trouble with uses a join to linkboth qryTotalPayments & qryTotalOrders.  The join type only includes rows where the joined field is equal.

The basic formula is

AmountOutstanding = qryTotalOrders!total - qryTotalPayments

The problem is the qry returns the values that look correct, ie people who have paid exactly what they have ordered show a $value of $0.00. The problem is if I click the cell that contains the value $0.00 the figure changes to 3.63797880709171E-12.  Why on earth would this be happening? Thanks in advance for any pointers

Question by:robjeeves
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16813900
what is the data type of the fields payments resp orders?
LVL 58

Accepted Solution

harfang earned 120 total points
ID: 16813994
Hello robjeeves

This looks like a rounding error. Computers normally do not perform exact math. For example, you can type this in the immediate pane:

    ? 1-(30001/3-10000)*3

And observe that the result is not 0, but 8.88178419700125E-16. This result reflects the fact that calculations are done with a certain number of digits (15 in this case), and that the remaining digits should be discarded.

If both your sums are really just that: sums of currency values without any calculation, Jet should propagate and automatically round the result to 4 decimals. Obviously, this is not the case, so that you should round the result yourself:

    AmountOutstanding = Round( qryTotalOrders!total - qryTotalPayments, 2 )
    AmountOutstanding = CCur( qryTotalOrders!total - qryTotalPayments )

It would probably be best to revise your queries (and perhaps even your data) to ensure they all have the currency type, or  convert any calculations to currency.

Good luck!

Expert Comment

ID: 16815586
AmountOutstanding = CCur(qryTotalOrders!total - qryTotalPayments)
LVL 44

Assisted Solution

Arthur_Wood earned 80 total points
ID: 16815742
just so you understand that what you are getting is NOT an error, the value you are seeing


is the same as 0.00000000000363797880709171

which is very close to 0.00 , and the reason is undoubtedly round-off error, as explained by harfang.


Author Comment

ID: 16829316
Thanks guys, I used the round formula suggested and it works a treat.  Most appreciated !!!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question