Results 1 to 7 of 7

Thread: How do I check if form is already loaded?

  1. #1
    Guest
    This must be an easy question for you guys.

    Thanks

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    If you meen another instance of your app then:
    [code]
    If App.PrevInstance Then
    MsgBox "Already Running"
    End
    End if
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    gwdash, thats for the program, I think that sandra means form

    and I think that this is what you want:

    Code:
    if form2.visible = true then
    'form 2 is loaded
    else
    if form2.visivle = false then
    'form 2 isn't loaded
    end if
    NXSupport - Your one-stop source for computer help

  4. #4
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    i know, i thought she might want program,
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  5. #5
    Addicted Member LAURENS's Avatar
    Join Date
    Jan 2000
    Location
    Utrecht, the Netherlands
    Posts
    138

    If it's loaded, it's in the forms collection.

    Sandra, once you've loaded a form, it's in the forms collection. so if you want to find out simply do something like this:

    Code:
    Private Sub Command1_Click()
    Dim frmLocal As Form
    
       If Not FormLoaded("Form2") Then
          Load Form2
          MsgBox "Form Loaded"
       Else
          MsgBox "Form2 already loaded"
       End If
             
    End Sub
    
    Public Function FormLoaded(strForm As String) As Boolean
    Dim frmLocal As Form
    
       FormLoaded = False
       For Each frmLocal In Forms
         
          If strForm = frmLocal.Name Then
             FormLoaded = True
             Exit For
          End If
       
       Next frmLocal
    
    End Function
    Regards,
    Laurens

    Using VB5 Enterprise edition SP3
    VB6 Enterprise edition SP5

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I would go with LAURENS suggestion because a form actually loads on first use. So if you check the Visible property the form will be loaded to check that property value.

  7. #7
    Guest
    Guys, you have been great! Yes, what Laurens said is exactly what I want, but I have learned something from other stuff posted here as an answer too.

    Thanks!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width