Checking for opened form

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

    #1

    Checking for opened form

    Hi

    How can I check in code if a form is currently open i.e. running?

    Thanks

    Regards


  • salad

    #2
    Re: Checking for opened form

    John wrote:
    Hi
    >
    How can I check in code if a form is currently open i.e. running?
    >
    Thanks
    >
    Regards
    >
    >
    You can use SysCmd
    ? SysCmd(acSysCmd GetObjectState, acForm, "FormName")

    0 = not open, 1 = design mode, 3 = open

    Or you can enumerate the open forms like this
    Function IsLoaded(strFor mName)
    Dim i
    IsLoaded = False
    For i = 0 To Forms.Count - 1
    If Forms(i).FormNa me = strFormName Then
    IsLoaded = True
    Exit Function
    End If
    Next
    End Function

    Comment

    • Randy Harris

      #3
      Re: Checking for opened form

      On Thu, 24 Aug 2006 21:23:28 GMT, salad <oil@vinegar.co mwrote:
      >John wrote:
      >Hi
      >>
      >How can I check in code if a form is currently open i.e. running?
      >>
      >Thanks
      >>
      >Regards
      >>
      >>
      >You can use SysCmd
      >? SysCmd(acSysCmd GetObjectState, acForm, "FormName")
      >
      >0 = not open, 1 = design mode, 3 = open
      >
      >Or you can enumerate the open forms like this
      >Function IsLoaded(strFor mName)
      Dim i
      IsLoaded = False
      For i = 0 To Forms.Count - 1
      If Forms(i).FormNa me = strFormName Then
      IsLoaded = True
      Exit Function
      End If
      Next
      >End Function

      Alternatively, if you use ADO, you could use the AllForms Collection.

      If CurrentProject. AllForms("frmMy Form").IsLoaded Then

      -=-=-=-=-=-=-=-=-=-=-=-=
      Randy Harris
      tech at promail dot com

      Comment

      Working...