Using Double Click event of TreeView from Microsoft Windows Common Controls 6.0 (SP6) (1 Viewer)

mdlueck

Sr. Application Developer
Local time
Today, 01:17
Joined
Jun 23, 2011
Messages
2,631
I discovered that there actually is a Double Click (DblClick) event the TreeView control found in Microsoft Windows Common Controls 6.0 (SP6) MSCOMCTL.OCX responds to.

You will not find it in the Events it publishes to Access. (See screen capture)



However, hand creating the correct event in the VBA editor indeed works.

Just take the name of the control as the first part of the event name, and then suffix the control name with "_DblClick()", as shown in my sample code:

Code:
Private Sub tvProjectReports_DblClick()

  Call Select_Click

End Sub
Badda bing, badda boom... the TreeView control obeys Double Click events now!

I am leaving the btnSelect button control, and have simply wired that event, and this event shown here, both to call the Select_Click event, where the meat of the event exists.
 
Last edited by a moderator:

mdlueck

Sr. Application Developer
Local time
Today, 01:17
Joined
Jun 23, 2011
Messages
2,631
I found the above technique of detecting Mouse Double Click events when running on Access 2010 not functional. Following is another method of attaching code to the Double Click event of the TreeView control, and this works with both Access 2007 / Access 2010.

Code:
Option Compare Database
Option Explicit

Private WithEvents ObjM_TreeView As mscomctllib.TreeView

Private Sub Form_Open(Cancel As Integer)

  'Set reference to the control object on the Form
  Set ObjM_TreeView = Me.tvProductReports.Object

End Sub

Private Sub ObjM_TreeView_DblClick()

  'Code to be executed when the Double Click event occurs...
  Call Me.Select_Click

End Sub
 

Users who are viewing this thread

Top Bottom