G
Guest
I thought this would be simple...help
I have a form that on-load sets focus on a short date field/label called
"nDate". I have a validation on this fields LostFocus to not be null or less
then Now() as follows...
Private Sub nDate_LostFocus()
If IsNull(nDate.Value) Then
MsgBox "Please enter DATE to start work.", vbExclamation, "MISSING FORM
DATE"Exit Sub
ElseIf nDate.Value < Format(Now(), "mm/dd/yyyy") Then
Msg = "The DATE you entered is in the past." & vbCrLf & "Would you like
to continue anyway?"
MsgStyle = vbYesNo + vbQuestion + vbDefaultButton2
MsgTitle = "PAST DATE"
response = MsgBox(Msg, MsgStyle, MsgTitle)
If response = vbYes Then
Exit Sub
ElseExit Sub
End If
End If
End Sub
....in return I don't wan't the user to be able to leave this field until the
validations are met but when I'm setting the >>Me!nDate.SetFocus<<ISSUE>> (as
pointed out above) at the end of the captured validation it does not seem to
work even though this looks to be the most logical approach.
Q. What am I not understanding about placing a SetFocus in the LostFocus
event of that same field?
Q. Is it possible to hold a user in a particular field until a validation is
met and how?
Thank you in advance for you assistance.
I have a form that on-load sets focus on a short date field/label called
"nDate". I have a validation on this fields LostFocus to not be null or less
then Now() as follows...
Private Sub nDate_LostFocus()
If IsNull(nDate.Value) Then
MsgBox "Please enter DATE to start work.", vbExclamation, "MISSING FORM
DATE"Exit Sub
ElseIf nDate.Value < Format(Now(), "mm/dd/yyyy") Then
Msg = "The DATE you entered is in the past." & vbCrLf & "Would you like
to continue anyway?"
MsgStyle = vbYesNo + vbQuestion + vbDefaultButton2
MsgTitle = "PAST DATE"
response = MsgBox(Msg, MsgStyle, MsgTitle)
If response = vbYes Then
Exit Sub
ElseExit Sub
End If
End If
End Sub
....in return I don't wan't the user to be able to leave this field until the
validations are met but when I'm setting the >>Me!nDate.SetFocus<<ISSUE>> (as
pointed out above) at the end of the captured validation it does not seem to
work even though this looks to be the most logical approach.
Q. What am I not understanding about placing a SetFocus in the LostFocus
event of that same field?
Q. Is it possible to hold a user in a particular field until a validation is
met and how?
Thank you in advance for you assistance.