Mark is correct, do the validation in the BeforeUpdate event. The problem
isn't that the code isn't moving the focus to txtDiskSerialNumber (serial is
misspelled), it's that it is doing this before Access moves the focus
because you tabbed out of the control, so the tab to the next control is
still taking effect, but after the code runs. Issuing the Cancel in the
BeforeUpdate if the validation fails will solve this problem. You won't need
the SetFocus statement.
--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
This code does not return focus to Me.txtDiskSerailNumber, it moves it
to the next textbox in the tab order. How can I force it to setfocus
where I want it.
Private Sub txtDiskSerailNumber_AfterUpdate()
If Len(Me.txtDiskSerailNumber) <> 8 And Len(Me.txtDiskSerailNumber)
<> 12 Then
MsgBox "Bad Serial Number ""Length""", vbCritical, "Input
Error"
Me.txtDiskSerailNumber.SetFocus
Exit Sub
End If
End Sub
Thanks, Rick