When I click on the "X" of access it activates the Form_Unload event procedure from the main form. I want to close all forms that are open before I exit the program with the following code.
What I find happening is that if I have more than one form open, it will close all the forms and leave one form open excluding the Main form that is conditionally not closed. What can I do to make sure that all forms close, and why does it according to my code leave one form open.
I also saw something on Isloaded but I do not know how to write it.
I will appreciate any help on this matter and thank you in advance for your help.
Code:
For Each frm In Forms
frmName = frm.Name
If frmName <> "Main" Then
DoCmd.Close acForm, frmName
End If
Next frm
What I find happening is that if I have more than one form open, it will close all the forms and leave one form open excluding the Main form that is conditionally not closed. What can I do to make sure that all forms close, and why does it according to my code leave one form open.
I also saw something on Isloaded but I do not know how to write it.
I will appreciate any help on this matter and thank you in advance for your help.