G
Guest
Greetings.
I have the following code, which tells the user that if the date is less
than the date in another field, 1) notify the user, 2) erase the incorrect
date and then 3) place the cursor back in the field to enter the correct
date. I can do steps 1 and 2, but for some reason step 3 will not work. Any
idea why it will not let me send the cursor to a control? I think I have
done it all correctly but I keep getting nowhere? I am thinking it is
because it is in an afterupdate event, but that just doesn't make sense to
me. Any thoughts would be highly appreciated. The code follows:
Private Sub txtDate_rcp_AfterUpdate()
Dim MoNo As String
Dim Yr As String
MoNo = DatePart("m", Me.txtDate_rcp)
Yr = DatePart("yyyy", Me.txtDate_rcp)
Me.txtMonth_rcp = MoNo
Me.txtYear_rcp = Yr
If Me![txtDate_rcp] < me![txtDate_org] Then
MsgBox "This date is before than the original tagged date. " &
vbCrLf & _
"You need to enter a valid date.", vbOKOnly, "Date Error"
Me![txtDate_rcp] = Null
Me![txtMonth_rcp] = Null
Me![txtYear_rcp] = Null
DoCmd.GoToControl "txtDate_rcp"
End If
End Sub
I have the following code, which tells the user that if the date is less
than the date in another field, 1) notify the user, 2) erase the incorrect
date and then 3) place the cursor back in the field to enter the correct
date. I can do steps 1 and 2, but for some reason step 3 will not work. Any
idea why it will not let me send the cursor to a control? I think I have
done it all correctly but I keep getting nowhere? I am thinking it is
because it is in an afterupdate event, but that just doesn't make sense to
me. Any thoughts would be highly appreciated. The code follows:
Private Sub txtDate_rcp_AfterUpdate()
Dim MoNo As String
Dim Yr As String
MoNo = DatePart("m", Me.txtDate_rcp)
Yr = DatePart("yyyy", Me.txtDate_rcp)
Me.txtMonth_rcp = MoNo
Me.txtYear_rcp = Yr
If Me![txtDate_rcp] < me![txtDate_org] Then
MsgBox "This date is before than the original tagged date. " &
vbCrLf & _
"You need to enter a valid date.", vbOKOnly, "Date Error"
Me![txtDate_rcp] = Null
Me![txtMonth_rcp] = Null
Me![txtYear_rcp] = Null
DoCmd.GoToControl "txtDate_rcp"
End If
End Sub