Do not allow more that 4 numerals in a text box

morlan

Registered User.
Local time
Today, 08:21
Joined
Apr 23, 2003
Messages
143
Hi guys,

I have 4 text boxes that are used to input a bank account number.
I have set the text boxes with an input mask of 0000 which stops the user from entering more than four numbers in each box.

I want to automatically set focus to the next box when the user has typed in 4 characters. I'm using this:

Code:
Private Sub txtACNumber1a_Change()

If (Len(Me.txtACNumber1a.Value) > 3) Then
    Me.txtACNumber2a.SetFocus
End If

End Sub

But the code won't fire! It works fine when I change the input mask back to blank. Any ideas what I can do?
 
Code:
Private Sub txtACNumber1a_Change()

If Len(Me.Me.txtACNumber1a.Value) = 4 Then
    Me.txtACNumber2a.SetFocus
    Me.Me.txtACNumber1a.Enabled = Flase
End If

End Sub

Just make it so that when it does equal 4 it moves on and locks it, but if they do move on without you can use a case stament to add zeros to either the back or front. :confused:
________
DC MARIJUANA DISPENSARY
 
Last edited:
a.sinatra said:
Code:
Private Sub txtACNumber1a_Change()

If Len(Me.Me.txtACNumber1a.Value) = 4 Then
    Me.txtACNumber2a.SetFocus
    Me.Me.txtACNumber1a.Enabled = Flase
End If

End Sub

Just make it so that when it does equal 4 it moves on and locks it, but if they do move on without you can use a case stament to add zeros to either the back or front. :confused:

Thanks mate, I think I've sorted it. :)
 
As an aside, I posted some code to limit the characters typed into a textbox in the Code Repository.
 

Users who are viewing this thread

Back
Top Bottom