Here is my routine that exits a program properly, after closing all forms and releasing all objects.
VB Code:
Private Sub ExitProgram_Click() Dim frm As Form Dim obj As Object If InventoryDeducted = False Then Call CloseInv ' If Necessary ! For Each frm In Forms If frm.Name <> Me.Name Then ' Unload this form LAST For Each obj In frm On Error Resume Next Unload obj Set obj = Nothing Next Unload frm Set frm = Nothing End If Next On Error Resume Next For Each obj In frm Unload obj Set obj = Nothing Next Set frm = Nothing Unload Me End Sub




Reply With Quote