Results 1 to 2 of 2

Thread: Find No. of Instances Open

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Question Find No. of Instances Open

    How do I find out how many instances of a particular Form are open?

    I tried this but it gives a wrong result:

    Code:
    Dim frm As Form
    
    For Each frm In Forms
        If (frm.Name = "Form1") Then
            MsgBox frm.Count
        End If
    Next


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Find No. of Instances Open

    vb Code:
    1. Dim frm As Form, frmcnt as long
    2.  
    3. For Each frm In Forms
    4.     If (frm.Name = "Form1") Then
    5.        frmcnt = frmcnt + 1
    6.     End If
    7. msgbox "Number of forms open is " & frmcnt
    8. Next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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