I have an application using a multiple document interface.
Attached is a very basic shell of one that will highlight my problem.
If I press the close button on the main MDI form I set a messagebox to appear asking if the user want's to save contents of each form or cancel the close.
Can anyone suggest a way to stop the loop so that if the user presses cancel on any of the message boxes it will cancel the close operation alltogether?
Try this.... Get a count of the forms before you ask them to unload. Then compare against the count after the unload call. If they are the same, then the user chose not to close:
Code:
Dim nrForms As Long
Dim chkme As Long
nrForms = Forms.Count
' loop thru them from last to first, so your mdi isn't counted
For chkme = Forms.Count - 1 To 1 Step -1
Unload Forms.Item(chkme)
If nrForms = Forms.Count Then
Cancel = True
Exit For
Else
nrForms = nrForms - 1
End If
Next chkme
Last edited by LaVolpe; Nov 7th, 2008 at 12:25 AM.
Insomnia is just a byproduct of, "It can't be done"
Actually, not quite...
Because you count backwards it doesn't start with the active form. So the messagebox that appears doesn't relate to the child form that is on top in the MDI form.
As they close I'd like the form that is closing to be visible.