Chris,
How about putting the validation code in the queryUnload() of the form? From your treeView, you would do something like:
if oCurrentForm.queryUnload()
oCurrentForm.release()
endif
In the queryUnload():
if (changesHaveNotBeenSaved)
nodefault
endif
This also prevents a user from using the close button (the 'X') on the form if the data validation does not pass.
One more thought...I think it is usually better to allow the users to have more than one form open at a time. They may be editing something on one form, and get interupted and need to look up something else on a another form.
>Yep that's the idea - they can flick about opening one form after another (when each form opens I store away it's name and when another form is launched I first programmatically close the previous form...) the idea is that in the lost focus I detect any changes made and trap the user on the form.
Steve Gibson