Treeview 6 MouseDown Event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jpatchak
    New Member
    • Oct 2006
    • 76

    Treeview 6 MouseDown Event

    Hello,

    I am trying to create a context menu for right clicking on a TreeView control (for deleting, etc...), using either the MouseDown or MouseUp event. When I put following code in:

    Code:
    Private Sub TestTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = acRightButton Then MsgBox ""
    End Sub
    I get an error message when I try to open the form with the TreeView on it:

    "The expression On Open you entered as the event property setting produced the following error: Prodcedure declaration does not match description of event or procedure having the same name"

    I have nothing in the form's On Open event. If I remove the mousedown sub from the code, everything compiles fine. Any ideas?
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hello.

    I have no problem to run the handler in my form.
    Have you checked Form.OnOpen property?
    Additionally that type of errors is usually caused by inappropriate functions/subs/global variables declarations.
    Sometimes it really appears without any reason and goes away without any obvious reason too. ;)
    Sometimes only full form rebuild helps. ;)

    Regards,
    Fish

    P.S. A stupid question - are you sure TestTree is the name of TreeView object, not the name of the form control embedding this object?

    Comment

    • jpatchak
      New Member
      • Oct 2006
      • 76

      #3
      Originally posted by FishVal
      Hello.

      I have no problem to run the handler in my form.
      Have you checked Form.OnOpen property?
      Additionally that type of errors is usually caused by inappropriate functions/subs/global variables declarations.
      Sometimes it really appears without any reason and goes away without any obvious reason too. ;)
      Sometimes only full form rebuild helps. ;)

      Regards,
      Fish

      P.S. A stupid question - are you sure TestTree is the name of TreeView object, not the name of the form control embedding this object?
      The Form.OnOpen property = "[Event Procedure]". I forgot that there is a call to a sub there to populate the tree. The sub runs fine if I don't have the Mousdown handler in the form's code.

      TestTree is the name of the object - I tested this by defining handlers for the object's dblClick event. I will try to rebuild the form and report the results.

      Comment

      • jpatchak
        New Member
        • Oct 2006
        • 76

        #4
        Originally posted by jpatchak
        The Form.OnOpen property = "[Event Procedure]". I forgot that there is a call to a sub there to populate the tree. The sub runs fine if I don't have the Mousdown handler in the form's code.

        TestTree is the name of the object - I tested this by defining handlers for the object's dblClick event. I will try to rebuild the form and report the results.

        Rebuilt - same problem. Added TreeView 6.0 control to a blank form. The only code I put in the module was the MouseDown handler - I get the same error except that instead of referring to On Open, it refers to On MouseMove. I tried to check the control's OnMouseDown property and I get "Object doesn't support this property or method." Same if I try to set the OnMouseDown property. This also happens when I try MouseUp. DblClick works, but I really need something that returns which mousebutton is clicked.

        Dumb question, but you're using VBA in Access right?

        Comment

        • FishVal
          Recognized Expert Specialist
          • Jun 2007
          • 2656

          #5
          Originally posted by jpatchak
          Rebuilt - same problem. Added TreeView 6.0 control to a blank form. The only code I put in the module was the MouseDown handler - I get the same error except that instead of referring to On Open, it refers to On MouseMove. I tried to check the control's OnMouseDown property and I get "Object doesn't support this property or method." Same if I try to set the OnMouseDown property. This also happens when I try MouseUp. DblClick works, but I really need something that returns which mousebutton is clicked.

          Dumb question, but you're using VBA in Access right?
          Sure I talk about VBA in Access.Form module.

          I have a little doubt as for event handler sub declaration.

          In you code it goes without argument pass type qualifier, so assumed by default as ByRef.

          Code:
          Private Sub TestTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
          If Button = acRightButton Then MsgBox ""
          End Sub
          In my code arguments are being passed ByVal.

          Code:
          Private Sub trvGroupsTree_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
              If Button = acRightButton Then MsgBox ""
          End Sub

          Comment

          • jpatchak
            New Member
            • Oct 2006
            • 76

            #6
            Thank You. It didn't work at first, but then I rebuilt the form w/ just the MouseDown handler (with ByVal qualifiers) and that worked. Then, I slowly copied code and controls from my old form. It appears to be working. Still very strange. I've got essentially identical forms with identical code modules and controls - one works and one doesn't. Weird. Thanks for your help!

            Comment

            • FishVal
              Recognized Expert Specialist
              • Jun 2007
              • 2656

              #7
              :)

              You are welcome.

              Regards,
              Fish

              P.S. I think some our experts known to launch S-300 rocket every time they here about using ActiveX in Access will be happy to have one more example of Fatal Error Produced By ActiveXXX.

              Comment

              Working...