Hi Bob,
Unfortunately, I am still getting the same problem, but will persevere. Are
you able to send me your test file so that I can check I have got everything
OK?
Ian
:
Update.
Try this version of the show module
Public Sub ShowUserFormByName(FormName As String)
Dim oUserForm As Object
On Error GoTo err
Set oUserForm = VBA.userforms.Add(FormName)
oUserForm.Show
Exit Sub
err:
Select Case err.Number
Case 424:
MsgBox "The Userform with the name " & FormName & _
" was not found.", vbExclamation, "Load userforn by name"
Case Else:
MsgBox err.Number & ": " & err.Description, vbCritical, _
"Load userforn by name"
End Select
End Sub
it seems to work with Me.Hide and Userform2.Hide.
Let me know if it works for you.
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
Hi Bob,
I have been giving this some further thought. Is it possible that,
because
the userform is declared in the form of a variable as opposed to using its
actual name, the 'true' name is never entered into memory and hence the
modal/topmost form is never registered against that name.
This would also explain why Unload [UserFormName] has no effect because
that
name has never been used. However, Unload Me would be unaffected as no
name
is needed.
Just a thought. Please don't laugh too loud if it's complete nonsense.
Ian
:
Yes, strange isn't it. I'll have to put my thinking head on, there is
obviously a rational explanation. I never encounter the problem, because
I
always use Unload Me and Me.Hide.
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
Absolutely perfect. Thanks once again.
It was a relief to know that you could reproduce it, as I was
beginning to
think I had just made a simple mistake.
Ian
:
Ian,
I have just knocked up a demo as I understand what you are saying,
and
totally unexpected, I was able to reproduce it. How perverse!
I have a solution for you though. don't use
Unload MarketAnalysis
but use
Unload Me
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
Bob,
The userforms now display perfectly. Many thanks.
However, the Cancel buttons on the subforms, which are connected
to
the
simple line (in this example where 'MarketAnalysis' is the name of
the
subform):
Unload MarketAnalysis
no longer works for any of the sub forms and has to be clicked
twice
for
the
main userform to be closed.
If I use the Hide command before Unload I get the error message
"Must
close
or hide topmost modal form first" when it runs the Hide command.
It must be connected to this recent code, becasue they used to
work.
Can
you think of any possible cause?