[AccessD] Decimal Data Type

Jim Dettman jimdettman at verizon.net
Thu May 15 08:32:30 CDT 2008


Tony,

<<Just out of curiosity (because I don't know what it is supposed to be 
used for) where would you use it in VBA?>>

  When you want accuracy for a specific number of decimal places.

  Floating point math by its very nature does not guarantee decimal
accuracy.  So if you use a single or double, the value to the right of the
decimal may not be accurate when you perform math operations with it.

  At first, VBA had the Currency type to work around this.  The Currency
type is a scaled integer fixed at four decimals.  What it does is if you
want to store a number like this:   1.2345, VBA grabs that, multiples it by
10000 and stores 12345.  When it hands the number back, it shifts the
decimal again and you get 1.2345.

  For some, that proved to inflexible so the decimal type was created.  With
it, you specify the scaling factor up to a limit of 28.  The bigger the
scale, the less range you have.

HTH,
Jim.

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
Sent: Thursday, May 15, 2008 8:37 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Decimal Data Type

Hey Gustav
How does Decimal differ from Double or Currency and do you know why it 
was added as a data type?  As Edward has confirmed when Access does the 
conversion "you have to hunt through the app and fix things by hand".

That said, Decimal should be avoided as data type in tables as it is known
to be buggy. In VBA, however, it can be quite useful.

Just out of curiosity (because I don't know what it is supposed to be 
used for) where would you use it in VBA?

Thanks
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list