FORCING A ZERO AT BEGINNING OF A NUMBER

W

William

I have a number of 4-digit numbers in a table that I need to show as a
5-digit numbers. For ex., 1234 needs to show as 01234.

What's the best way to do this?
 
P

PvdG42

William said:
I have a number of 4-digit numbers in a table that I need to show as a
5-digit numbers. For ex., 1234 needs to show as 01234.

What's the best way to do this?

Define the column as text.
 
J

John W. Vinson

I figured it out:

Change the data type to number, and then Format/00000.

Note that this will *DISPLAY* with leading zeros but will not *STORE* leading
zeros. The numbers 123, 00123, and 000000000000123 are all exactly the same
number and - in a number field - will be indistinguishable.

If this "number" is an identifier (such as a US Zip code or an item number),
then it should be stored in a Text field, not a number field. You can use an
input mask of

"00000"

to force entry of five numeric digits, or some code in the AfterUpdate event
of a form textbox to zero fill:

Private Sub txtTextbox_AfterUpdate()
If Len(Me!txtTextbox) < 5 Then
Me!txtTextbox = Right("00000" & Me!txtTextbox, 5)
End If
End Sub
 
D

dianne

als je ziek bent meld je dan ook ziek en laat het nooit zien aan de mensen
als je ongenegens echt ziek bent maar als of en dan ook nog niet ziek melden
dan zeg ik je verdiendt je werk niety
 

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