stop a MDI child form from closing if parent is trying to close

J

JohnR

I have a form that is presented in an mdi child window. If the user hits
exit or the X button on the titlebar of the mdi child form, that form's
"closing" event fires and in that event I check to see if there are any
outstanding database changes that have not been saved. If there are I give
the user the option of abandoning the closing of the form by issuing a
"e.cancel" statement. This works perfectly if the user hits the X in the
titlebar of the MDI child form, but if the user hits the X in the titlebar
of the MDI parent form then the "e.cancel" has no effect and the form closed
anyway.

Is there a way to cancel a form close of a mdi parent form from within the
mdi child form?

thanks, John
 
C

Cor Ligthert [MVP]

John,

You can check if there are existing MDI childs in the close event of the
parent.

if Me.mdichildren.lenght > 0 then
e.cancel etc.

You can as well get the specific one. You have than to loop through it and
check its name.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top