Hello all,
I've written a validation check to make sure users using a userform enter a valid employee ID or kiosk number, but also to prevent the users from leaving the box blank. The coding was working, but now it only seems to be working intermittently. When testing there are times when I leave the box blank, my msgbox message comes up, but the majority of times, nothing happens. Does anyone know why this may be occurring, or how I can add another validation to ensure the user cannot enter an invalid employee id #, kiosk #, or leave the field blank? I also thought, if the user entered a value that was invalid, my setFocus line would take them back to the PERNR text box, instead it places the cursor within the next box they would enter, which is the Rep name box. Here's a snippet of the code I'm using:
Private Sub txtPERNR_AfterUpdate()
If Len(Me.txtPERNR.Text) <> 8 Or Me.txtPERNR.Text <> "9999" Or Me.txtPERNR.Text = "" Then
Me.txtPERNR.SetFocus
MsgBox ("Please enter valid PERNR # or 9999 for kiosk entry")
ElseIf Me.txtPERNR.Text = "9999" Then
Me.txtKioskNo.SetFocus
MsgBox ("Please enter in kiosk ticket number and date IT ticket was opened (mm/dd/yyyy)")
End If
End Sub
Thanks for any and all help!
Damian37
Bookmarks