Public Sub UnloadAllForms(sFormName As String)
Dim Form As Form For Each Form In Forms If Form.Name sFormName Then Unload Form Set Form = Nothing End If Next Form End Sub 'This is a sub, that you would probably use from the Form_Unload of your 'Main form. So here is the code for that: Call UnloadAllForms Me.Name 'Also, here is the code if you're calling it from other Subs: Call UnloadAllForms "" There has been a lot of stories about how Visual Basic doesn't unload the forms when you exit the program. This is a 'resource killer'. So here is the code I received from somewhere. This unloads all of the forms in your program. |