Results 1 to 2 of 2

Thread: Form Open Status

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    22

    Form Open Status

    Hi, may i know how to use VBA to check whether the form-- "form1" is open or closed?

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Form Open Status

    I think you would probably have to use the FindWindow API to do this. The reason is, any time you reference a form, it gets instantiated. So, the test:
    VB Code:
    1. If UserForm1 Is Nothing Then
    will always evaluate to false--the form will be "not nothing" as soon as the test is made. The way around these issues would be to never let a form load implicitly. Do all of your form loading by setting a variable for the form and explicitly creating and destroying it's reference:
    VB Code:
    1. Dim oForm As UserForm1
    2.  
    3. Set oForm = New UserForm1
    4. oForm.Show
    5. Set oForm = Nothing

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