Reputation: 13
I have a workbook which has multiple layers of userforms.
When the workbook is opened the user is presented with a userform which has two command buttons, one which selects a worksheet with pivottable and slicers and a second which opens another userform containing eight command buttons, seven of which call further individual userforms and the eight which is a close button.
The issue I have is that when I select the command button which opens a new userform, then close the second userform and then reselect the command button to reopen the second userform, the second userform appears but none of the command buttons work nor the close window (X).
The code behind the first command button is as follows:
Private Sub cmd_manageAbsence_Click()
splashScreen.Hide
Load managementFunctions
managementFunctions.Show
End Sub
The close and terminate code on the second userform is as follows:
Private Sub cmd_close_Click()
Unload managementFunctions
End Sub
Private Sub UserForm_Terminate()
Sheets("Front").Activate
splashScreen.Show
End Sub
I am having the same issues with the second layer of userforms, but I guess if I get the first layer sorted I can apply the fix to the rest.
Thanks
Upvotes: 1
Views: 1843
Reputation: 3290
You should try
Unload Me
instead of
Unload managementFunctions
Also, you might want to look at the difference between Form.Show
and Form.ShowDialog
(https://msdn.microsoft.com/en-us/library/aa984358%28v=vs.71%29.aspx ... i realise this is an old page, but the info is still valid!)
Furthermore, you might also benefit from creating your form objects as follows:
Dim frm as managementFunctions
set frm = new managementFunctions
frm.Show
and then you can use
Me.Hide
instead of Unload Me
Upvotes: 2