Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load object based on string name?

Status
Not open for further replies.

Qaroven

Programmer
Nov 14, 2000
74
AU
OK my prob is this ..

I have a table which contains among other things the names of Form objects in the project in question.

I want to load a form (eg Load Form1, Form1.Show, etc) based on the string form name from the table - and NOT by a select statement like

select case sObjectName
case "Form1":
Load Form1
...

Suggestions .. (would be easy if VB had eval) Ben
+61 403 395 052
 

if you have all the forms already loaded (but not displayed), you could loop through the Forms collection to find the one that you want.

dim f as Form

for each f in Forms
If UCase(f.name) = UCase(sObjectName) Then
f.Show
Exit For
End If
Next
 
SauerC,
Yes, your method would work as long as there were not a lot of forms. If you had an app with a lot of forms (my last job was on an app with over 200 forms), you would be wasting a lot of memory and the app would take forever to start up as all of the forms got loaded.
Sad to say, however, I can not think of a better way to do this.
- Jeff Marler B-)
 
SauerC has hit the nail on the head .. I don't currently have many forms, but it may pan out that way, and I DON'T want to have them all loaded in memory (not to mention some of the large recordsets some of them may display) Ben
+61 403 395 052
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top