Number field with preceeding 0?

R

Rachel

Is it possible to have a variable be a number field and
not drop a preceeding 0?
For example, I have ID numbers that start 0123456 but the
front 0 drops out. I'd prefer not to have the field be
text. Is there a solution?

Thanks!
 
A

Adrian Jansen

Assuming you know how many leading digits you want, set the format property
of the associated control to

"0000000" - to show 7 digits with leading zeroes.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
I

Immanuel Sibero

Hi

That's just not the way numbers are stored in the computer. But you can use
the Format() function to do this.

test = 3
format(test, "000000") evaluates to 000003


HTH
Immanuel Sibero
 
J

Jeff Boyce

Rachel

Numbers typically don't bother with preceding 0s -- the 0s don't add
anything to the process of adding, subtracting, multiplying, ...

On the other hand, there are "codes" that look like numbers and need to keep
their preceding 0s -- East Coast, USA has several zipcodes starting with "0"
(e.g., "02123").

If you are referring to "ID numbers", odds are you won't be doing math on
them. Make them a text type field if STORING the zero is important. If
DISPLAYING the leading zeros is important, the other responders have pointed
out the Format() function.

Good luck

Jeff Boyce
<Access MVP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top