>>If you enter something in a textbox and press escape, the keypress event will fire before the textbox.valid enabling the form to close immediately. However, if the user clicks on the X (close) box, the textbox.valid fires before the queryunload method and there is no obvious way to inform the valid method that the user wants to close the form, not have the textbox contents validated. Is there a workaround?
>
>Put the following in your base Form class KeyPress method:
>LPARAMETERS nKeyCode, nShiftAltCtrl
>IF nKeyCode = 27 AND nShiftAltCtrl = 0
> IF This.ActiveControl > 0 AND NOT This.ActiveControl.Valid()
> NODEFAULT
> RETURN
> ENDIF
>ENDIF
>DODEFAULT()
>
*********
I want the form to close. My problem is that I also want the form to close when the user clicks on the X box, without running the textbox.valid, or at least have some way for the textbox.valid to know that the reason it fired is because the user clicks the X box, then it could just RETURN .T. and not validate.
Dr. Ken A. McGinnis
Healthcare software design