>I have a form. On the form is a Pageframe with two pages. Each page has a ADD/SAVE button and a DONE/CANCEL button.
>
>If the use presses the "X" button, I want to validate that there are no unsaved changes.
>
>I've put the following code in various methods
>NODEFAULT
>WITH thisform.pageframe1
> IF .pages(.activepage).cmdAdd_Save.caption = "Save"
> =MESSAGEBOX("You have unsaved changes"+CHR(10)+"Please press <Save> or <Cancel>")
> RETURN .F.
> ELSE
> DODEFAULT()
> ENDIF
>ENDWITH
>
>When I put this in the Form Release method the code didn't fire when I clicked the X.
>
>When I put this in the Form Unload method, the pageframe had already been unloaded and an error was generated.
>
>When I put this in the Destroy method, the messagebox popped up, but the form closed anyway.
>
>Similar syntax works correctly in the page Deactivate event.
>
>I could really use some advice on the correct event to code and the proper syntax to make this work the way I would like.
>
>Thanks to all.........Rich
Validation code should go to Form.QueryUnload event.
Edward Pikman
Independent Consultant