problem with Access Currency Field 
Author Message
 problem with Access Currency Field

Hi I am producing a program that runs on an Access table.  This table has a
currency field in it.  The problem that I have got is that an Access
currency field has 4 decimal places and I wish to round it to 2 decimal
places.  The problem is that a number held like 10.99 will become 10.9901
instead or 10.9898.  There seams to be no way to round these figures up to 2
decimal places.  I have tried to take the figures out and round them up to
two decimal places but when the figures are returned to the database it just
seams to go back to the old price.

Is there any way to make a Access Currency field round up to 2 decimal
places.

I am using the BDE and Access 97

Thanks in advance

--

Patrick Matthews



Tue, 05 Aug 2003 22:11:30 GMT  
 problem with Access Currency Field
This function rounds number to any selected decimal space

unit BeliUnit2;

interface
Uses SysUtils,math;

function RoundFloat(Num:extended;dec:byte):extended;

implementation

function RoundFloat(Num:extended;dec:byte):extended;
var
    nu,f:extended;
    k,i:integer;
begin
 if ((dec<1) and (dec > 13 )) then //1-13 decimal spaces
  begin
   result:=0;
   exit;
  end;
 f:=power(10,dec);
 nu:=frac(num)*f;
 i:=round(nu);
 k:=round(frac(nu)*10);
 if k>4 then k:=1 else k:=0;
 i:=i+k;
 result:=round(num)+(i/f);
end;

end.

On Fri, 16 Feb 2001 14:11:30 -0000, "Patrick Matthews"

Quote:

>Hi I am producing a program that runs on an Access table.  This table has a
>currency field in it.  The problem that I have got is that an Access
>currency field has 4 decimal places and I wish to round it to 2 decimal
>places.  The problem is that a number held like 10.99 will become 10.9901
>instead or 10.9898.  There seams to be no way to round these figures up to 2
>decimal places.  I have tried to take the figures out and round them up to
>two decimal places but when the figures are returned to the database it just
>seams to go back to the old price.

>Is there any way to make a Access Currency field round up to 2 decimal
>places.

>I am using the BDE and Access 97

>Thanks in advance

>--

>Patrick Matthews


Regards,
E.Beli
http://www.greenhousemm.com


Thu, 07 Aug 2003 11:36:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Currency field display format

2. Alternative for currency field

3. Currency Fields

4. Currency Field lossing precision

5. Rounding errors and paradox currency fields

6. Money field type same as Currency data type??

7. D1, Interbase, and currency fields

8. Currency format problem

9. EURO, Dual currency problems

10. Currency Problems

11. Problem: Change Currency to Euro?

12. Currency Problem with Delphi

 

 
Powered by phpBB® Forum Software