Making mask in a table

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

Guest

I want to make a mask in a table. It should be min 4 numbers in txt format
Eks. 1 should be 0001 not 1, 123 shoul be 0123.
 
Let's say that the field size is 10. The input mask would be:

0000######

That makes the first four digits mandatory and the last 6 digits optional.
If any of the last 6 aren't entered, they are NOT stored as spaces.
 
Una said:
I want to make a mask in a table. It should be min 4 numbers in txt
format Eks. 1 should be 0001 not 1, 123 shoul be 0123.

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.
 
Hi Una

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.




Hope this helps
 
ooops

If SomeName = Len("FieldName") < 4 Then

Should be

If SomeName = Len("FieldName") < 5 Then
 

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

Similar Threads

Numeric Field 7
SQL Statement 1
Input Mask in tables 2
input mask formatting is lost when tables are formed to a union qu 2
Input masks 1
Input masks 4
Leading Zeros 7
Number Reverts to Zero 5

Back
Top