Are you using a text field or a number field. Tables do not same
numbers with leading zeros. You can display numbers with leading zeros as a
format in queries(?), reports and forms. If you choose text then you will
not be able to do math computations on the text.
I would not bother with a mask. - Up to you though.
If you are using a form to update the record I would use the AfterUpdate
event of the control to alter the data. Something like this
Private Sub FieldName_AfterUpdate()
If Len(Me.FieldName) < 5 Then
Me!FieldName = Right("0000" & Me!FieldName, 4)
End If
End Sub
Change "FieldName" to what it is on the form and it should be OK.
If the data is "always" 4 digits you could set this as a variable and use
something like this
Private Sub FieldName_AfterUpdate()
Dim SomeName As Long
If SomeName = Len("FieldName") < 4 Then
Me!FieldName = Right("0000" & Me!FieldName, 4)
End If
End Sub
Change FieldName again and I wouldn't use "SomeName" so change this as well.
Note this will of course trim the data to 4 so don't use if this is not
what you want (not really sure from your post). Or include an "else" to the
above to show longer strings.
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.