I am facing a problem in loading forms in VB, by calling the form name through a variable. Like :
dim ank as string
ank = "frmMain"
Load ank
the above code is giving me problems and I am unable to figure out a way to get past this problem. I think that the solution would be easy for you experts with years experience but silly me could not get through this small problem. I would really appreciate all the help I can get with this problem of mine.
Chalo that will be all for now. TAKE CARE you guys and gals.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
unfortunately, even we with years of experience don't have anything except workarounds for this problem. Unless the form is not loaded, you can't get it's object reference and check it's name, and thus you can't load one (as the load function requests an object).
CHeers
Dim frmToLoad As Form
dim ank as string
ank = "frmMain"
Set frmToLoad = Forms.Add (Ank)
which does work. Of course if the string contains a form that is not present in the project then an error will occur but this can be trapped and handled in the usual way.
CHeers