Loading forms from (string) names

I need to be ableto load forms and manipulate then when I do not necessarily know the name at design time. For example, I could plug in additional forms and get the file and form names from an external text file.

It isn't important actially to "add" the form at run time, just load it into focus from a string name at run time.
LVL 1
scj1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
You could solve this by using a simple SelectCase..EndSelect block structure like this

Select Case FormNameToLoad
Case "frmMain"
  Load frmMain
Case "frmAnother"
  Load frmAnother
End Select

This is probably the only solution possible I'm afraid. You can scan thru the .vbp file to see all the possible form names. Lines starting with 'Form=' contains a form name.
0
watyCommented:
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 20/09/1999
' * Time             : 11:59
' **********************************************************************
' * Comments         : Loading a Form using a String
' *
' *
' **********************************************************************
Sub LoadFormByString(sFormName As String)
   Dim NewForm As Form
   Set NewForm = Forms.Add(sFormName)
   NewForm.Show
End Sub
0
VbmasterCommented:
I have to add that waty's solution only works in VB6.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

GuryTraubCommented:
Hey you can get the string name of the form with your host (container) father form (MDI..)
This can be your line to get the name of the form

name = MDImain.ActiveForm.name
0
scj1Author Commented:
The first comment by vbmaster is the one I used (its a VB6 Enterprise app so it worked perfectly).

If you post it again you can have the points. Incidently, if you know how to do the same with datareports I'd appreciate it (i've increased the points slightly as a sweetner!)

Thanks,

StuJ.
0
VbmasterCommented:
Sometimes the simplest method is the best. ;)

Unfortunately I have no idea what you mean with datareports, I have done almost nothing with DAO databases.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scj1Author Commented:
Thanks,

StuJ
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.