Text field 000

bunji

Registered User.
Local time
Today, 15:35
Joined
Apr 26, 2005
Messages
124
I have a field that has a property of text, this is because on occasions a user will need to enter a letter. However mostly they just enter a number.

This number is usually 000925 and obviously it goes to just two 00 when above a thousands. I would like to set it that if the user just enter 925 then three 000 will appear before the number or two or one etc.

by changing the format of the box to 000000 works fine for a number field but how can i do it on a text field. Any ideas?
 
Let's say that the name of your field is txtCode.
In the OnUpdate()-parameter of your field, enter the following code in VBA:

Code:
If Len(Me.txtCode.Value) = 1 then Me.txtCode.Value = "00000" & Me.txtCode.Value
If Len(Me.txtCode.Value) = 2 then Me.txtCode.Value = "0000" & Me.txtCode.Value
If Len(Me.txtCode.Value) = 3 then Me.txtCode.Value = "000" & Me.txtCode.Value
If Len(Me.txtCode.Value) = 4 then Me.txtCode.Value = "00" & Me.txtCode.Value
If Len(Me.txtCode.Value) = 5 then Me.txtCode.Value = "0" & Me.txtCode.Value

Quick and dirty, I know, but it should work!

Good luck!

Seth
 

Users who are viewing this thread

Back
Top Bottom