Number field with preceeding 0?

  • Thread starter Thread starter Rachel
  • Start date Start date
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!
 
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
 
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
 
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>
 
Back
Top