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