>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()
Mark McCasland
Midlothian, TX USA