By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,462 Members | 2,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,462 IT Pros & Developers. It's quick & easy.

How do I stop access from removing decimal places?

AdezziFan420
P: 1
Hi All,
I'm having some trouble here with my access database. When I input a number followed by a decimal and a zero it will display that way in the table. For example I write "15.0" into my text box and then add it to the table, I look at the table and a 15.0 is there.

But when I call that field in the table using VBA it will return as a 15. I need the ability to add a ".0" when it is an integer. Currently it will return other decimals correctly.

I have the data type set in the field to a Single. I have also tried setting it to a double but the same thing happens. I feel like access should be capable of doing this. Please let me know if i'm missing anything.

Thank you.
Aug 14 '17 #1

✓ answered by NeoPa

It's important to understand the difference between what's stored and what's displayed. If you want to enter 1.0 and have 1.0 returned then you're probably thinking of a string. Strings are strings and what you enter is what you get. As strings though, they aren't designed to be arithmetically manipulable.

Numbers, however, are different beasts entirely. What you enter is evaluated and stored in a form that you probably wouldn't recognise if opened in Notepad for instance. In Access there are various defaults for how to display numbers (or number formats). Unless otherwise specified a default format will be used. This is generally equivalent to as many as necessary digits before the point; a point if necessary; as many as necessary digits after the point.

Not always what you want, and not what you want in this particular instance.

Never worry. Most places values are displayed from the data there will be a Format property you can use to control how they're displayed. In those rare cases where there isn't such (In the various Print statements for instance.) you can use the Format() function instead.

NB. Always remember that values should be converted to a human visible format when, and only when, they are at the very last step. Once converted to human-readable form the converted value is no longer of any use as a number.

PS. Join the club! (of ADezii fans :-))

Share this Question
Share on Google+
4 Replies


PhilOfWalton
Expert 100+
P: 1,430
Depending on the size of the number, Single should be fine.

It will probably be stored as 15 in the table, but using the Format function, there are many ways of displaying it.

I suggest you try
Expand|Select|Wrap|Line Numbers
  1. format(MyNumber,"#.0")
  2.  
Where MyNumber is your number. This will format it with one decimal place

Phil
Aug 14 '17 #2

NeoPa
Expert Mod 15k+
P: 31,186
It's important to understand the difference between what's stored and what's displayed. If you want to enter 1.0 and have 1.0 returned then you're probably thinking of a string. Strings are strings and what you enter is what you get. As strings though, they aren't designed to be arithmetically manipulable.

Numbers, however, are different beasts entirely. What you enter is evaluated and stored in a form that you probably wouldn't recognise if opened in Notepad for instance. In Access there are various defaults for how to display numbers (or number formats). Unless otherwise specified a default format will be used. This is generally equivalent to as many as necessary digits before the point; a point if necessary; as many as necessary digits after the point.

Not always what you want, and not what you want in this particular instance.

Never worry. Most places values are displayed from the data there will be a Format property you can use to control how they're displayed. In those rare cases where there isn't such (In the various Print statements for instance.) you can use the Format() function instead.

NB. Always remember that values should be converted to a human visible format when, and only when, they are at the very last step. Once converted to human-readable form the converted value is no longer of any use as a number.

PS. Join the club! (of ADezii fans :-))
Aug 18 '17 #3

P: 9
You could just adjust your field settings by going to the tables property settings. Instead of " number" as the value use text. You will also see an option to change the decmial placement to 0
Aug 22 '17 #4

NeoPa
Expert Mod 15k+
P: 31,186
Unfortunately, while that may save you from one small problem it opens you up to a whole bunch of other nasty problems. Simply using text is certainly not an advisable solution.

You'll find this already explained in detail in my earlier post.
Aug 22 '17 #5

Post your reply

Sign in to post your reply or Sign up for a free account.