Put the following code in the first control's Change event procedure,
substituting the name of your next control for SomeOtherControl:
Dim ctrl As Control
Set ctrl = Me.ActiveControl
If Len(ctrl.Text) = 6 Then
Me.SomeOtherControl.SetFocus
End If
This also allows a user to enter character(s) in the middle of a string of
less than 6 characters and automatically move focus to the next control, but
does not prevent a user entering a character in the middle of an existing
string of 6 characters, however, so to cater for that put the following code
in the first control's KeyPress event procedure:
Const conBACKSPACE = 8
Dim ctrl As Control
Set ctrl = Me.ActiveControl
If Len(ctrl.Text) = 6 Then
If KeyAscii <> conBACKSPACE Then
KeyAscii = 0
End If
End If
This also allows for the use of the backspace or delete key to delete
characters. You will find, however, that if a user wants to substitute a
string for an existing value in the control or a substring in part of a
control of 6 characters then they won't be able to select the string to be
replaced and overtype it. Instead they'd have to delete the selection and
then enter the replacement string.
Ken Sheridan
Stafford, England