Showing VB Forms via string variable 
Author Message
 Showing VB Forms via string variable

In follow-up to an earlier post, I asked how to load a VB6 form based on a
string variable (i.e. similar to the Access DoCmd.OpenForm strFormname).  That
problem was solved via the Forms.Add command to load it into the collection.

But now I need to find a way to show a particular form based on a name
contained in a string variable.  I need a form to 'pop-up' based on a user
selected check box. The name of the form is stored in a table and is transfered
to the tag of the control on form load.  How can I take this string value in
the tag property of the control and open the corresponding form?  The .Show or
.Load commands do not seem to accept a string variable (only an integer index).
 I am looking for something similar to Show(strFormname).  I have tried
declaring a new form and setting the .Name property equal to the string, but VB
reports that the name is a read-only property at runtime.

The only solution I have found is to loop through all forms in the collection
until a matching name is found:
Dim frm as Form
For each frm in Forms
   if frm.Name = strFormname then
       exit sub     ' Kick out of loop
   end if
Next frm

This works but seems a little inefficient, especially if many forms are loaded.
 Is this the only solution in VB6, or is there another way to open a particular
form based on a string parameter?

Thanks in advance (and thanks for previous help!).
Steve Herriford
Indianapolis, IN

Fri, 06 Sep 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. ???????? GURUS - Showing or Loading Forms by use of String variable containing Form Name

2. How to show a form from a string variable

3. Forms Collection: Using it to Open Forms by Passing the Form Name as a String Variable

4. How to load a show from a string variable

5. Show a form modal to Outlook via a COM Add-in

6. showing forms using variables????HEELP

7. showing a form based on a variable?

8. Show a form from a variable

9. Show Variable in Forms Title Bar

10. Show Form with formname given in a variable

11. Referring to a form via variable

12. Showing forms using a string


Powered by phpBB® Forum Software