By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,326 Members | 1,899 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,326 IT Pros & Developers. It's quick & easy.

Treeview 6 MouseDown Event

P: 76
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub TestTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  2. If Button = acRightButton Then MsgBox ""
  3. End Sub
  4.  
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?
Aug 21 '08 #1
Share this Question
Share on Google+
6 Replies


FishVal
Expert 2.5K+
P: 2,653
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?
Aug 21 '08 #2

P: 76
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.
Aug 21 '08 #3

P: 76
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?
Aug 21 '08 #4

FishVal
Expert 2.5K+
P: 2,653
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TestTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  2. If Button = acRightButton Then MsgBox ""
  3. End Sub
  4.  
In my code arguments are being passed ByVal.

Expand|Select|Wrap|Line Numbers
  1. Private Sub trvGroupsTree_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
  2.     If Button = acRightButton Then MsgBox ""
  3. End Sub
  4.  
Aug 21 '08 #5

P: 76
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!
Aug 21 '08 #6

FishVal
Expert 2.5K+
P: 2,653
:)

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.
Aug 21 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.