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

In an appliocation I am working on I have developed a sub-routine that will
open any form requested by the calling application.  It works by adding the
name of the requested form (passed as a string variable) to the Forms
collection.

the relevant code is something like this:

Sub OpenForm(byVal strFormName as String)
dim frm as Form, i as Integer

    'check if the form is already open
     For i = 0 To Forms.Count - 1
        If Forms(i).Name = strFormName Then
                Forms(i).Show
                Exit Sub
        End If
     Next i

      'if not open a new one
      Forms.Add strFormName
      Set frm = Forms(Forms.Count - 1)
      frm.Show 0

End Sub

This works absolutely fine as long as the application is run from the VB
project environment.  as soon as I make an .exe it stops working.  The
application doesn't give an error, and it doesn't hang up.  It just stops
executing the function at the "Forms.Add strFormName" statement, and passes
control back to the calling application without executing the following
statement.

I am at a loss to understand what is happening here.  Any ideas would be
welcome.



Sun, 02 Sep 2001 03:00:00 GMT  
 Forms Collection: Using it to Open Forms by Passing the Form Name as a String Variable
David,

Check out KB article Q194912.

--
HTH
VB-Joker

PLEASE post ALL replies to newsgroup!


Quote:
>In an appliocation I am working on I have developed a sub-routine that will
>open any form requested by the calling application.  It works by adding the
>name of the requested form (passed as a string variable) to the Forms
>collection.

>the relevant code is something like this:

>Sub OpenForm(byVal strFormName as String)
>dim frm as Form, i as Integer

>    'check if the form is already open
>     For i = 0 To Forms.Count - 1
>        If Forms(i).Name = strFormName Then
>                Forms(i).Show
>                Exit Sub
>        End If
>     Next i

>      'if not open a new one
>      Forms.Add strFormName
>      Set frm = Forms(Forms.Count - 1)
>      frm.Show 0

>End Sub

>This works absolutely fine as long as the application is run from the VB
>project environment.  as soon as I make an .exe it stops working.  The
>application doesn't give an error, and it doesn't hang up.  It just stops
>executing the function at the "Forms.Add strFormName" statement, and passes
>control back to the calling application without executing the following
>statement.

>I am at a loss to understand what is happening here.  Any ideas would be
>welcome.



Mon, 03 Sep 2001 03:00:00 GMT  
 Forms Collection: Using it to Open Forms by Passing the Form Name as a String Variable
Thanks for the pointer - I had completely missed this in my trawl of the
support sites, and it certainly explains what is happening.  Unfortunately
the suggested workaround doesn't entirely solve our problem, and given that
there is no short term forecast of the bug being fixed we have had to adopt
a different approach, but at least we now know where we stand.

Thanks again

David

Quote:

>David,

>Check out KB article Q194912.

>--
>HTH
>VB-Joker

>PLEASE post ALL replies to newsgroup!



>>In an appliocation I am working on I have developed a sub-routine that
will
>>open any form requested by the calling application.  It works by adding
the
>>name of the requested form (passed as a string variable) to the Forms
>>collection.

>>the relevant code is something like this:

>>Sub OpenForm(byVal strFormName as String)
>>dim frm as Form, i as Integer

>>    'check if the form is already open
>>     For i = 0 To Forms.Count - 1
>>        If Forms(i).Name = strFormName Then
>>                Forms(i).Show
>>                Exit Sub
>>        End If
>>     Next i

>>      'if not open a new one
>>      Forms.Add strFormName
>>      Set frm = Forms(Forms.Count - 1)
>>      frm.Show 0

>>End Sub

>>This works absolutely fine as long as the application is run from the VB
>>project environment.  as soon as I make an .exe it stops working.  The
>>application doesn't give an error, and it doesn't hang up.  It just stops
>>executing the function at the "Forms.Add strFormName" statement, and
passes
>>control back to the calling application without executing the following
>>statement.

>>I am at a loss to understand what is happening here.  Any ideas would be
>>welcome.



Wed, 05 Sep 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How do I open a form by passing the Name of the form as a string

2. opening a form using a string containing form name

3. Opening a Form when form name is a text string

4. Opening a Form when form name is a text string

5. How to open form when all I have is name of form in a string

6. calling a contol on a form using a string for the form name

7. Open form, close form, open form = disposed object exception

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

9. Need Form object given only the form name (string)

10. Form name is Text, how do I open form

11. How To Open a Form from an Array of Form Names

12. passing focus info form form to form

 

 
Powered by phpBB® Forum Software