Is a from loaded

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Is a from loaded

    Hi,

    How can you tell if a form is loaded, or visible?

    would this work (from form2)

    if form1.visible = true then
    ''CODE HERE
    end if

    Steve.



  • Dillon Mantle

    #2
    Re: Is a from loaded

    [color=blue]
    > if form1.visible = true then
    > ''CODE HERE
    > end if[/color]

    That should work. But remember, forms that are loaded are not always
    visible. So maybe you can set a flag to track the form.

    Dim I_am_Open as Boolean

    Private Sub Form1_Load()
    I_am_Open = true

    end sub

    Then in the other form

    If I_am_Open = true then
    CODE
    end if

    Remember to change the flag when you close the form


    Comment

    • Steve Gerrard

      #3
      Re: Is a from loaded


      "Steve" <alex_is_a_cunt @twat.com> wrote in message
      news:EoudnRuQF9 PxM5zdSa8jmA@ka roo.co.uk...[color=blue]
      > Hi,
      >
      > How can you tell if a form is loaded, or visible?
      >
      > would this work (from form2)
      >
      > if form1.visible = true then
      > ''CODE HERE
      > end if
      >
      > Steve.
      >
      >
      >[/color]

      Actually no. If form1 is not loaded, the above line of code will load
      it! That is the snag of using the "intrinsic" instance variables for
      forms - they are loaded automatically anytime they are referenced in
      code.

      You could iterate through the forms collection, looking for a form of a
      particular name:

      Public Function FormIsLoaded(Fo rmName As String) As Boolean
      Dim oFrm As Form

      For Each oFrm In Forms
      If oFrm.Name = FormName Then
      FormIsLoaded = True
      Exit For
      End If
      Next oFrm

      End Function



      Comment

      • Steve

        #4
        Re: Is a from loaded

        "Dillon Mantle" <dillonm@dasolu tions.co.za> wrote in message
        news:f7WdnWysUI [email protected]...[color=blue]
        >[color=green]
        > > if form1.visible = true then
        > > ''CODE HERE
        > > end if[/color]
        >
        > That should work. But remember, forms that are loaded are not always
        > visible. So maybe you can set a flag to track the form.
        >
        > Dim I_am_Open as Boolean
        >
        > Private Sub Form1_Load()
        > I_am_Open = true
        >
        > end sub
        >
        > Then in the other form
        >
        > If I_am_Open = true then
        > CODE
        > end if
        >
        > Remember to change the flag when you close the form
        >
        >[/color]

        Cheers Fellows,

        My question is answered, thankyou.

        Steve.


        Comment

        Working...