FORCING A ZERO AT BEGINNING OF A NUMBER

  • Thread starter Thread starter William
  • Start date Start date
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?
 
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.
 
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
 
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
 
Back
Top