I've set a validation within my userform to force the user to enter in a valid employee ID or a general kiosk #. The validation is working, but the setFocus line I have added to place the cursor back in the textbox in the event the value entered was incorrect isn't working. The cursor is moving on to the next textbox making the user have to re-click on the text box in order to correct the invalid entry. Am I placing my setFocus line in the wrong place of the code? FYI - The second setFocus is working correctly. When the user enters 9999 it directs them to the IT Ticket number text box. Prior to me moving the textbox, the cursor would jump all other text boxes to allow the user to enter in a ticket number within the ticket number box after entering 9999 within the PERNR text box. Any ideas????
Private Sub txtPERNR_AfterUpdate()
If Len(Me.txtPERNR.Text) <> 8 And Me.txtPERNR.Text <> "9999" Or Me.txtPERNR.Text = "" Then
MsgBox ("Please enter in valid PERNR # or 9999 for a kiosk entry")
Me.txtPERNR.SetFocus
ElseIf Me.txtPERNR.Text = "9999" Then
Me.txtKioskNo.SetFocus
MsgBox "Please enter in kiosk ticket number."
End If
End Sub
Damian37
Bookmarks