Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    77

    Unanswered: Detecting loaded forms.

    hi all,

    Anyone know how to detect whether a form is already loaded?

    thx in advance.

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    copied straight from Access help files ! Not my work:


    Sub AllOpenForms()
    Dim frm As Form, ctl As Control

    For Each frm In Forms

    Debug.Print frm.Name

    Next frm
    End Sub


    This will give you every form name that is open.
    Last edited by Ken_Hart; 03-23-04 at 04:52.

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try this function:

    Function IsFormLoaded(ByVal strFormName As String) As Boolean
    ' Gibt den Wert "True" zurück, wenn das angegebene Formular in Formularansicht
    ' oder Datenblattansicht geöffnet ist.

       Const conObjStateClosed = 0
       Const conDesignView = 0


    &nbsp;&nbsp; If SysCmd(acSysCmdGetObjectState, acForm, &nbsp;&nbsp;&nbsp;&nbsp;strFormName) <> conObjStateClosed Then
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Forms(strFormName).CurrentView <> conDesignView Then
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; IsFormLoaded = True
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If
    &nbsp;&nbsp; End If

    End Function

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    English Translation:
    Code:
    Function IsLoaded(ByVal strFormName As String) As Boolean
        ' Returns True if the specified form is open in Form view or Datasheet view.
        
        Const conObjStateClosed = 0
        Const conDesignView = 0
        
        If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
            If Forms(strFormName).CurrentView <> conDesignView Then
                IsLoaded = True
            End If
        End If
    End Function
    Usage:
    Code:
    If IsLoaded("myFormName") Then
       MsgBox"Form myFormName is Loaded."
    End If
    Last edited by CyberLynx; 03-24-04 at 00:43.

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Thanks for CyberLynx translating the remarks, I forgot to do it.

Posting Permissions

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