Stop Cursor from moving to next record

jammin140900

Registered User.
Local time
Tomorrow, 00:30
Joined
Aug 18, 2008
Messages
35
Hi All,

I have some data validation for some date fields as listed below. This method works fine but the only thing is by using Me.FileCompleteDate = " " , the cursor moves along straight away to the next field instead of sticking to the same field and allowing the user to input the correct date. Is their a way around this please?

Regards
J

Private Sub FileCompleteDate_AfterUpdate()
If Me.FileCompleteDate < Me.ApplicationReceivedDate Then
MsgBox "File Complete Date must be greater than Application Received Date", vbCritical + vbOKOnly, "Date Validation Error"
Me.FileCompleteDate = ""
End If
End Sub

Private Sub FileCompleteDate_Change()
If Me.FileCompleteDate < Me.ApplicationReceivedDate Then
MsgBox "File Complete Date must be greater than Application Received Date", vbCritical + vbOKOnly, "Date Validation Error"
Me.FileCompleteDate = ""
End If
End Sub
 
Perhaps you should try the BeforeUpdate event.

If your criteria is not met then:
Code:
Msgbox...
Cancel = True

I believe this will retain focus on your control.

Evan
 
Hi Evan,

I tried that and it didn't work. It's a subform in datasheet view. I'm not sure if that's the reason it doesn't work?
 
Hi Evan,

This didn't seem to work. This is a subform in datasheet view. Does that make the difference?
 
Evan,

My apologies. I didn't put it in correctly and so it didn't work.

You're suggestion is spot on. It now works. Thank you.

Regards
J
 

Users who are viewing this thread

Back
Top Bottom