I hope that I can make this make sense.
I have several user forms called, e.g., "UserForm1" through "UserForm50"
I want to set a variable called "FormIs" to represent one of the user
forms. I want to select the appropriate user form from a dropdown list that
I have created, populated with the 50 UserForm names.
I have assign to the result of my selection from the dropdown list to
the variable SelectedName. The return value of SelectedName is a string
variable. SelectedName might have a value of "UserForm17", but that is not
the same as the form UserForm17.
I know how to assign FormIs to the actual object UserForm17. I just
type:
Set FormIs = UserForm17
But assigning FormIs to a string variable SelectedName cannot be done by
merely typing:
Set FormIs = SelectedName (because SelectedName is a variable, not an
object)
How can I convert FormIs or SelectedName to the actual object I want it
to represent?
Ed - 07 Jul 2007 20:20 GMT
Hi Ed,
Until a better suggestion comes along ...
You might be able to use a Select Case statement, e.g.
Dim FormIs as Object
...
...
Select Case SelectedName
Case "UserForm1"
Set FormIs = New UserForm1
Case "UserForm2"
Set FormIs = New UserForm2
...
...
End Select
Regards.
(Another) Ed
> I hope that I can make this make sense.
>
[quoted text clipped - 20 lines]
> How can I convert FormIs or SelectedName to the actual object I want it
> to represent?
Ed - 08 Jul 2007 11:46 GMT
Ed-
Brilliant! Thanks.
(other) Ed
"Ed"
> Hi Ed,
>
[quoted text clipped - 48 lines]
>> it
>> to represent?
Ed - 08 Jul 2007 16:16 GMT
You're welcome :-)
Regards.
(An) Ed
> Ed-
>
[quoted text clipped - 56 lines]
> >> it
> >> to represent?