LOCAL lnReply, lnGoToPageOnCancel, lnRetVal lnGoToPageOnCancel = 0 IF !CBaseForm::QueryUnload() NODEFAULT RETURN .F. ENDIF *-------------------------------------------- *-- Write out the contents current control *-------------------------------------------- IF !this.WriteBuffer() NODEFAULT RETURN .F. ENDIF *--------------------------------------------- *--- Cancel all "new and empty" records in all *--- business objects on the form *--------------------------------------------- lnRetVal = This.CancelAllNewAndEmpty() *---------------------------------------------------- *-- If adding a new record but nothing entered yet *---------------------------------------------------- IF lnRetVal = FILE_OK *---------------------------------------------------- *--- If the record has been changed by the user... *---------------------------------------------------- IF This.IsChanged() *-------------------------------------------- *--- If this form has an nGoToPageOnCancel *--- property, set it to zero so another *--- page is not activated upon selecting *--- Yes or No to AskToSave() *-------------------------------------------- IF PEMSTATUS(This,"nGoToPageOnCancel",5) lnGoToPageOnCancel = This.nGoToPageOnCancel This.nGoToPageOnCancel = 0 ENDIF *--------------------------------------- *--- Ask if they want to save changes *--------------------------------------- lnReply = This.AskToSave() IF lnReply = IDCANCEL OR lnReply = IDMUSTKEY *------------------------------------------- *--- Reset the nGoToPageOnCancel property *--- if it has been changed. *------------------------------------------- IF lnGoToPageOnCancel != 0 This.nGoToPageOnCancel = lnGoToPageOnCancel ENDIF NODEFAULT RETURN .F. ENDIF ENDIF ENDIF>It is my understanding that if I let my forms have a close button, when the user clicks on the close button, the form will close and there is nothing my code can do to stop the close. I can get control in QueryUnload (and save the data in the form if it passes all the validations or throw it away if it fails the validations). In Word if I click on the close button in the upper right, I am given the option to stop the close (if there is unchanged stuff in the document). My VFP apps should behave the same way. What do I do?