Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

UserForm

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 07 Jul 2007 14:11 GMT
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?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.