| 'Within a form module Private Sub Form_Activate() 'Form_Activate is a logical place to do this Dim oFrm As Form For Each oFrm In Forms if oFrm.Name <> me.Name and Not _ (TypeOf oFrm Is MDIForm) then Unload oFrm Next End Sub 'OR: As a function in a .Bas or .cls module 'use the name of form you don't want unloaded as parameter Public UnloadAllExceptOne(FormToStay as String) dim oFrm as Form for each oFrm in Forms if oFrm.Name <> FormToStay and Not _ (TypeOf oFrm Is MDIForm) then unload oFrm next End Sub |
Unload all forms except for the current one |
Express News India | Freelance ecommerce web development India