Compeltion Pop Up Message

linanderson

Registered User.
Local time
Today, 01:40
Joined
Jul 13, 2002
Messages
17
I have the following code used on a OnClick event of a control on a form:

If IsNull(Me.ClientSurname) Then
Cancel = True
MsgBox "Mandatory. Please complete client surname", vbOKOnly + vbCritical, "Error"
Me.ClientSturname.SetFocus
End
End If


I want to ensure is that when the focus goes to the field with Null, the user cannot move to another field before completing this field. I thought 'Cancel = True' would work, but it does not.

Additionally, if this field is completed and then the data is cleared, the message is not received again. Is there a way of getting around this?
 
Try putting your validation code in the BeforeUpdate event, setting Cancel to True if the validation fails.
 
Thanks for replying.

I already have the code on the BeforeUpdate event on the form aswell and the same issue occurs.

Wherever I place the Cancel=True part of the code, after the focus is set to a field, you can move to another field. What I thought would occur is that you could not move from the field once the focus had been set and a entry completed?

Perhaps, this cannot be done but I got the idea from:

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=30576&highlight=dont+pass+go
 
Try the "On Lost Focus" event of the field in question. Test if the field is Null and set the focus back to that field if it is Null.

HTH
 

Users who are viewing this thread

Back
Top Bottom