Results 1 to 7 of 7

Thread: need to check if form is open

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    need to check if form is open

    e.g

    if Form1 is open then Unload Form1
    if Form7 is open then Unload Form7

    etc, any ideas how?

  2. #2
    Hyperactive Member vincentg's Avatar
    Join Date
    Jun 2005
    Location
    Chicago IL, USA
    Posts
    261

    Re: need to check if form is open

    You can see it using loop thru the Forms Collection...
    Then unload it..

    I think somebody few hours ago posted something like that here...

  3. #3

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: need to check if form is open

    Here it is...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Activate()
    4.   Dim frm As Form
    5.   For Each frm In Forms
    6.     If frm.Name = "Form1" Or frm.Name = "Form7" Then
    7.       Unload frm
    8.     End If
    9.   Next
    10. End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: need to check if form is open

    thanks, could i put that code in a module and do

    Call Form_Activate in the function of my form?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: need to check if form is open

    Quote Originally Posted by Pouncer
    thanks, could i put that code in a module and do

    Call Form_Activate in the function of my form?
    Form_Activate is an event in all forms and fires when the form is loaded.

    The question is: at what point in your application do you need to know whether these forms are still loaded?

  7. #7

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