[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Whats New!
Need a database?
Tips via email
Learn VBA
Questions Answered
Access Tips Index
What is MS Access

Formatting Numbers

 

Formatting Numbers. I do not know about you, but I have awful trouble deciding what number formats Microsoft Access provides for what situations, and then they do not often give the format you require. As an example, you may wish to display leading zeros in an AutoNumber field (0001, 0002, 0003…..0010, 0011, etc.) or you may wish to display zeros to a number of decimal points, i.e. .1200 instead of just .12, or even a zero before the decimal point, i.e. 0.1200.

Have you ever wondered how you can achieve this?

The secret is to manually type in your own format. For example, if you wish to display the above examples then, in the format property section of the field in the table, query, form or report, you would type the following (as opposed to selecting the format from the drop down list).

Leading zeros in an AutoNumber field:

000000 or however many zeros you want.

To display .12 as .1200 then you would enter the following:

.0000

Or, to display a leading zero as well you would type in:

0.000

What these manual zeros do is tell Microsoft Access that a number HAS to fill these spots. If a number is not provided either by you or the database user, then Microsoft Access fills the empty spots with zeros. This is why it works - simple if you know how….

 

Do you like this tip? Subscribe to my Newsletter to receive tips via email. Click Here to subscribe.

 

www.simply-access.com (c) 2002 - 2009