G
Guest
I have a user form that I am providing an error message if the enter an
incorrect date. I want to then set the focus back to the date field after
the error. I am using the below code to do this however it is not setting
the focus back to the date field? Am I doing something wrong or is their a
property on the fields that overrides the "setfocus"?
Any help would be greatly appreciated.
Private Sub DateRec_Exit(Cancel As Integer)
If DateDiff("d", DateRec, Now) > 30 Or DateDiff("d", DateRec, Now) <
0 Then
MsgBox "Date is either in the future or entered in an incorrect
year. Please re-enter"
Me.DateRec.SetFocus
End If
End Sub
incorrect date. I want to then set the focus back to the date field after
the error. I am using the below code to do this however it is not setting
the focus back to the date field? Am I doing something wrong or is their a
property on the fields that overrides the "setfocus"?
Any help would be greatly appreciated.
Private Sub DateRec_Exit(Cancel As Integer)
If DateDiff("d", DateRec, Now) > 30 Or DateDiff("d", DateRec, Now) <
0 Then
MsgBox "Date is either in the future or entered in an incorrect
year. Please re-enter"
Me.DateRec.SetFocus
End If
End Sub