Not rounding decimals

Marinus

I'm learning... :)
Local time
Today, 20:57
Joined
Jun 16, 2010
Messages
140
Hi All,

Would someone be able to help me to eliminate rounding decimals in my app. Although I am not the destructive type I am now ready to throw the PC out of the windows.. Would a Dim as Long statement round decimals when used? as all through my table and forms and reports I have consistently fixed numeric format with 2 decimal places and still the decimals are rounded to Zero..

My table field is decimal, fixed format 2 steps..

Any help appreciated..
 
Reece

Dim x as long means that whatever is passed to that variable will not have any decimal places. It will be a whole number. You need to change the datatype to Double.
 
Reece

Dim x as long means that whatever is passed to that variable will not have any decimal places. It will be a whole number. You need to change the datatype to Double.

For one I am glad you thought me to look in the right place, tried everything else except Double which I must have overlooked . Your a genius..
 
As David intimated, the Long datatype is a "Long" integer. Single and Double are floating point.

Single generally works reasonably well to about three decimal places.

Long is capable of storing very large numbers and does also contribute to precision. However it is still possible to get rounding errors on divisions that would be expected to return an integer and this must be accounted for in the code or control design.

The highest precision datatype is the Decimal. It is comprised of an integer with a scaling factor. However the developer needs to understand the precison and scaling factors when defining field's datatype in the table. The correct factors need to be applied for the range of numbers to be stored.

In VBA the Decimal is a strange beast. It is not a datatype in its own right but a case of the Variant datatype.

It is set up by:

Dim x as Variant
x = CDec(x)

There is no contol over the scaling and precision so I don't know what happens there. Maybe it makes a judgement based on the value.
 
Thank you my Friend,
Found some of it on the internet, actually all but this sums it up easier..
 

Users who are viewing this thread

Back
Top Bottom