Set number of decimals on the fly

Stephanpls

New member
Local time
Today, 17:21
Joined
Dec 28, 2008
Messages
8
I am writing code in which I create a table and fill it with data. At the end of the code I open the table. All works fine. The nuisance is that the table fields with real numbers are shown with many decimals. I know how to set the number of decimals in the table design window, but I did not find out how to set it in VBA code. Does anyone know?

Thanks.
 
You should only use tables to store data not to display it. Use forms/reports for displaying data. When you display data you can use the FORMAT function to select how many decimal places you want to display. See Access help for more info
 
Thank you. So it's not possible to change such settings in VBA, then?
 
Thank you. So it's not possible to change such settings in VBA, then?
You can use the FORMAT function in VBA. The way Access stores real numbers means that there can be a ot of decimal digits that you often don't need to display. As I previously said you shouldn't display directly from a table. Use a form or report instead.
 
a number is a number

say you want to store 1/3 of a dollar for some reason - then your system will store .3333333333 etc of a dollar

so say you decide to store 33 cents, then you use a rounding function to coerce the value to 33 cents - but it is important to realise that 33cents is NOT exactly a third of a dollar, and you have to bear this in mind when calculations

ie 1000 items at 1/3 dollar each is not the same as 1000 items at 33cents each
 

Users who are viewing this thread

Back
Top Bottom