Hi,
I have searched for hours trying to solve what should be a simple process. Please excuse me if I am missing something very obvious.
I have a userform (MTScoringForm) that shows modal. One of the button controls hides the MTScoringForm and opens a modeless form (frmOKModeless) to allow the user to directly edit a worksheet. Upon closing the modeless form I want the MTScoringForm to show again.
I use this same modeless form (frmOKModeless) to allow user interaction with the worksheet in other situations, requiring hiding and re-showing of other modal userforms. So I am trying to pass the initiating userform to the frmOKModeless as a variable.
If I use userforms.add (variable), it creates a new instance of the userform. To investigate, I created what should be a simple process (based on the advice from AlphaFrog: http://www.mrexcel.com/forum/excel-questions/710098-putting-userform-variable.html)
I can successfully test for the name of the objUserForm in the first "Test" procedure, and can pass the userform as a string to ShowUserformA. But that creates a new instance of the form, not a re-showing of the existing, loaded form. When I try to pass it as an object to ShowUserformB, I get a Run-time error '438' ("Object doesn't support this property"). Can anyone help me understand where I'm going wrong?
Thanks!
I have searched for hours trying to solve what should be a simple process. Please excuse me if I am missing something very obvious.
I have a userform (MTScoringForm) that shows modal. One of the button controls hides the MTScoringForm and opens a modeless form (frmOKModeless) to allow the user to directly edit a worksheet. Upon closing the modeless form I want the MTScoringForm to show again.
I use this same modeless form (frmOKModeless) to allow user interaction with the worksheet in other situations, requiring hiding and re-showing of other modal userforms. So I am trying to pass the initiating userform to the frmOKModeless as a variable.
If I use userforms.add (variable), it creates a new instance of the userform. To investigate, I created what should be a simple process (based on the advice from AlphaFrog: http://www.mrexcel.com/forum/excel-questions/710098-putting-userform-variable.html)
Code:
Sub TEST()[INDENT]Dim objUserForm As Object
Set objUserForm = MTScoringForm
Load objUserForm
ShowUserformA ("MTScoringForm") 'Pass as string[/INDENT]
[INDENT]ShowUserformB (objUserForm) 'Pass as object
[/INDENT]
End Sub
Sub ShowUserformA(Byval strShowA as string)[INDENT]
UserForms.Add(strShowA).Show[/INDENT]
End Sub
Sub ShowUserformB(ByVal objShowB As Object)[INDENT]
objShowB.Show[/INDENT]
End Sub
I can successfully test for the name of the objUserForm in the first "Test" procedure, and can pass the userform as a string to ShowUserformA. But that creates a new instance of the form, not a re-showing of the existing, loaded form. When I try to pass it as an object to ShowUserformB, I get a Run-time error '438' ("Object doesn't support this property"). Can anyone help me understand where I'm going wrong?
Thanks!