I want to check that a valid date has been input to Textbox, but I want to trap the error before the user can move on to the next field on the Userform. I am trying to do it in the
Private Sub Attend_1_Exit
I can trap the error OK but I cannot set the focus back on the field with the incorrect date. Instead focus has moved to the next field on the form. I am using the following code. Can anybody help please?
Private Sub Attend_1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Baddate As Integer
If IsDate(Attend_1) = False Then Baddate = 1 Else Baddate = 0
If Baddate = 0 Then GoTo FinishOK Else
Dim Answer As Integer
Ans = MsgBox("You must enter a valid date", vbRetryCancel)
Select Case Answer
Case vbRetry
AttendanceForm!Attend_1.SetFocus
Case vbCancel
AttendanceForm!Attend_1.SetFocus
End Select
FinishOK:
End Sub
Bookmarks