PDA

View Full Version : Solved: Userform



stapuff
03-07-2008, 07:02 AM
I have searched for hours looking for a way to close all Userforms on commandbutton click (Regardless of weather they are the active userform (on top) or deactivated userform (on bottom). I have all of my userforms ShowModal = False


Private Sub CmdBtn1_Click()
Call All_UF_Close
UF_DashBrd.Show
UF_CreateWO.Show
End Sub


I have tried everything I can think of to achieve the following, however, it does not close the deactivatated UF located on the bottom.



Public Sub All_UF_Close()
UF_CreateWO.Hide
Unload UF_CreateWO
DoEvents
UF_UpdateWO.Hide
Unload UF_UpdateWO
DoEvents
UF_CancelWO.Hide
Unload UF_CancelWO
DoEvents
UF_CloseWO.Hide
Unload UF_CloseWO
DoEvents
End Sub

mikerickson
03-07-2008, 07:11 AM
This should unload all loaded userforms
Do Until UserForms.Count < 1
Unload UserForms(0)
Loop

stapuff
03-07-2008, 07:22 AM
Mike -

Outstanding!

Thank You

A Q if I might - a UF on top or bottom is still loaded but Top = active Bottom = deactive?

mikerickson
03-07-2008, 07:29 AM
I'm only familiar with modeless userforms.
That's the way they work for me.