I have a subForm with a default view of DataSheet. In this subform, I have a field named txtCourse_Date. If the user enters a year that is less than the current year minus two (YEAR(NOW()) - 2), then I want to tell the user to correct the data.
The problem that I'm having is that if they click on another row of data in the datasheet, the message does not execute. The same thing seems to occur if the user clicks on a button located on the main form that the subform is attached to.
Here is the code that I'm currently using. Should I take another approach when trying to keep the cursor in the txtCourse_Date cell?
Here is what I'm currently doing:
Thanks,
Crhodus
The problem that I'm having is that if they click on another row of data in the datasheet, the message does not execute. The same thing seems to occur if the user clicks on a button located on the main form that the subform is attached to.
Here is the code that I'm currently using. Should I take another approach when trying to keep the cursor in the txtCourse_Date cell?
Here is what I'm currently doing:
Code:
Private Sub txtCourse_Date_Exit(Cancel As Integer)
If Not IsNull(txtCourse_Date.Value) Then
If (Year(txtCourse_Date.Value)) < ((Year(Now())) - 2) Then
MsgBox ("The year that you entered into the Course Date falls outside the 2 year CE window. Please correct the year or delete this record.")
''// Keep focus in the txtCourse_date field. //
Cancel = True
Exit Sub
End If
End If
End Sub
Thanks,
Crhodus