Making a number x digits long

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have various codes that I'm currently storing as text. However, they only
have a numeric part. The reason I used text is because a number inputted as
009003 would be stored as 9003 if its datatype was a number. The zeros at the
start are actually important to the end user. Obviously, I know that each
code is 6 digits long so could append the zeros for display purposes. Any
ideas how to do this? In Java I cast the number to a String, get the length,
and append the correct number of zeroes. What's the VBA equivalent?

Thanks

Dave
 
To force the value of SomeField to display as 6 digits with leading zeros:
Format([SomeField], "000000")
 
I have various codes that I'm currently storing as text. However, they only
have a numeric part. The reason I used text is because a number inputted as
009003 would be stored as 9003 if its datatype was a number. The zeros at the
start are actually important to the end user. Obviously, I know that each
code is 6 digits long so could append the zeros for display purposes. Any
ideas how to do this? In Java I cast the number to a String, get the length,
and append the correct number of zeroes. What's the VBA equivalent?

It SHOULD be text, not Number, if leading zeroes are relevant. 9003
and 009003 and 0000000009003 are the same number!

Use a Text field with an Input Mask of

000000

and the user will be obligated to enter six numeric digits.

John W. Vinson[MVP]
 
Thanks everyone. Would it be possible to have the default set at 000000, then
as the user types the number, the 0's get overwritten (ie 000000 becomes,
00000x becomes, 0000xx)?
 
Back
Top