Data validation

Malcy

Registered User.
Local time
Today, 07:27
Joined
Mar 25, 2003
Messages
584
Going slightly skewy on this one. I want user to confirm date entered is OK and if not to clear field back down and allow entry of new date. Sounds reasonable to me and I am sure I have done it before but cannot find the line of code.
I have got
Code:
Private Sub txtNewMot_AfterUpdate()
    Dim varResponse As Variant
    
    varResponse = MsgBox("You are about to enter a new MOT date. Are you sure?", vbYesNo, "Confirmation required")
    
    If varResponse = vbNo Then
        Me.txtNewMot = Null
    End If
    
End Sub
But if I hit the no button it nulls out the field as wanted but sets the focus to the next field on the form, not the txtNewMot field.
Edit - just realised I removed the code Me.txtNewMot.SetFocus since it was not working
Anyone got any ideas what is going on?
Thanks
 
Use the before update event. If you want to cancel the update you can use Cancel=true
 
Thanks Keith
It is so obvious when you see it. Must be time for more coffee!!
 

Users who are viewing this thread

Back
Top Bottom