>Here's an answer from Nigel to this same question:
>
>"First line of valid: If LastKey()=27 Return .T. - this should do it. Your cancel button will need to be cancel=.t. (I think it will work then)."
>
>If you can swing it, a PUTM is great for the ability to search on stuff like this...
>
>Michelle
>
I think there is a big problem with this solution (that is, checking the lastkey()) !!!
If the last key the user pressed was the escape key and since then, he didn't use the keyboard anymore (only his mouse) and then he tries to quit the field with the valid routine suggested above USING HIS MOUSE, the lastkey still returns 27 though he didn't quit the fields using escapekey, so the validation won't execute though it should !!!!!
BTW : A similar problem exists with the validroutine in gridfields ... (one can quit a field in a grid using the mouse, bypassing it's validmethod, leaving the gridfield with an unchecked value)
My suggestion :
let the valid routine accept an empty value or a correct value ; when the OK/SAVE/WHATEVER button is pressed check if there are any fields that are empty but shouldn't and refuse the OK/SAVE/... if there are empty fields that shouldn't.
Disadvantage : the user has to clear the field first if he wants to cancel ...