Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    47

    Unanswered: is form opened...

    Hey

    This sould be an easy question. Is there a way to determine if a particular form is opened?

    Situation:
    Form1 --> opens Form3
    Form2 --> opens Form3

    Form3 needs to know which form opened it (Form1 or Form2)

    Thanks.
    F..ck it, gimme a beer... Jimi Hendrix RULES!

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Open form3 using OpenArgs
    DoCmd.OpenForm FormName:="YourFormName", OpenArgs:="Form1"

    Then when form3 is opened it has a persistent property of OpenArgs. You can evaluate it with If Me.OpenArgs = "Form1", etc.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Nov 2003
    Location
    Warren, PA
    Posts
    52
    Create a module

    Function IsLoaded(ByVal strFormName As String) As Integer
    ' 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

    Then you can call the module to find if any form is open

    msgbox IsLoaded("Formname")


    Brent

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by bhummel
    Create a module

    Function IsLoaded(ByVal strFormName As String) As Integer
    ' 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

    Then you can call the module to find if any form is open

    msgbox IsLoaded("Formname")


    Brent
    Thank you sir!

    I'll have to add that one to my bag o' tricks.

    Usually I create a try..except handler and try to reference the form, returning an exception if it's closed. This is much more elegant, danke!

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by bhummel
    Create a module

    Function IsLoaded(ByVal strFormName As String) As Integer
    ' 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

    Then you can call the module to find if any form is open

    msgbox IsLoaded("Formname")


    Brent
    Thank you sir!

    I'll have to add that one to my bag o' tricks.

    Usually I create a try..except handler and try to reference the form, returning an exception if it's closed. This is much more elegant, danke!

Posting Permissions

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