G
Guest
I have a form named subSearchLima (not really a subform) where I have a
control called "newDOB". The form is used for data entry, and I have VB code
that, on Update of newDOB, compares it to a field on another open form
(SearchLima). The logic for the comparison is working, but I can't get the
focus to stay on newDOB if the string is not equal to the comparison field.
The default enter key behavior is continuing to move it to the next field on
the form, whether the logic is true or false. I have also tried using the
next field to move the focus back On Enter, but haven't been able to get that
to work either.
Here is the VB code in the After_Update section of newDOB:
Private Sub newDOB_AfterUpdate()
Dim gotDOB As Date
Dim getNew As Date
gotDOB = Forms!SearchLima!DOB
getNew = Me.newDOB
If getNew = gotDOB Then
ExamYear.SetFocus
Else
Me.newDOB = Null
newDOB.SetFocus
End If
End Sub
Here was the code I was trying in the next field (ExamYear) on Enter:
Private Sub ExamYear_Enter()
If Me.newDOB = Null Then
newDOB.SetFocus
End If
End Sub
Any help would be much appreciated.
Regards,
Bill
control called "newDOB". The form is used for data entry, and I have VB code
that, on Update of newDOB, compares it to a field on another open form
(SearchLima). The logic for the comparison is working, but I can't get the
focus to stay on newDOB if the string is not equal to the comparison field.
The default enter key behavior is continuing to move it to the next field on
the form, whether the logic is true or false. I have also tried using the
next field to move the focus back On Enter, but haven't been able to get that
to work either.
Here is the VB code in the After_Update section of newDOB:
Private Sub newDOB_AfterUpdate()
Dim gotDOB As Date
Dim getNew As Date
gotDOB = Forms!SearchLima!DOB
getNew = Me.newDOB
If getNew = gotDOB Then
ExamYear.SetFocus
Else
Me.newDOB = Null
newDOB.SetFocus
End If
End Sub
Here was the code I was trying in the next field (ExamYear) on Enter:
Private Sub ExamYear_Enter()
If Me.newDOB = Null Then
newDOB.SetFocus
End If
End Sub
Any help would be much appreciated.
Regards,
Bill