Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / September 2006

Tip: Looking for answers? Try searching our database.

Round function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claire - 30 Sep 2006 02:27 GMT
Hi

Dont know exactly how to explain.

I have a field name cost, currency 4 digits afler dot.
The second field is setup to Round cost 2 digits after dot.

The problem is
If  my cost is like : 1.0050 when I round (cost;2)
it give me the result of 1.00
It did not recongnise the 5 and then not give me
1.01
I tought to add in my procedure
a variable call priceok

If right (2)[cost] = 5 then     of *(4 digits)
  right (1)[priceok] = 1       of *(2digits)
else
price = round(cost;2)
endif

I am trying to find a solution. May bee you can help.

I hope

Thanks in advance

Claire
Steve Schapel - 30 Sep 2006 04:11 GMT
Claire,

The Round() function moves an exact 5 in the trailing place to the
nearest even number.  So...
 Round(1.115;2) = 1.12
 Round(1.125;2) = 1.12
 Round(1.135;2) = 1.14
 Round(1.005;2) = 1.00
... etc.

This is correct, and by design.  It helps to balance out inaccuracies
that would arise with totals or averages of large numbers of items if
the rounding always happened in one direction.

So, if for some reason you want your database to behave differently, you
will, as you suggested, need to use something other than the simple
Round() function.  I think this will work...
 Price = Round(([Cost]*100+0.005)/100,2)

Signature

Steve Schapel, Microsoft Access MVP

> Hi
>
[quoted text clipped - 16 lines]
> price = round(cost;2)
> endif
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.