userform label double-click goes to click event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a VBA form that I'm using in Excel 2002. On one label in the form, I
want to run one function from the click event and another from the
double-click event. However, when I double-click the label, I always get the
click event. I've checked the double-click speed from control panel and it
seems to be ok. The form is *not* being shown modal.

Have a nice day
John Paul Fullerton
 
That seems to be by design: (from help on dblClick)

For this event to occur, the two clicks must occur within the time span
specified by the system's double-click speed setting.
For controls that support Click, the following sequence of events leads to
the DblClick event:

1. MouseDown
2. MouseUp
3. Click
4. DblClick

If a control, such as TextBox, does not support Click, Click is omitted fom
the order of events leading to the DblClick event.

Perhaps use Right Click for the second action.
 
Thank you for the note.

Could you let me know more about this?

When I go to the form design screen, I can select dblclick for the label and
I put code in that event (and other code in the click event). Eventually I
just put msgbox's in both to let me know what event I was accessing. When I
double-click the label when the macro is running and the form is displayed,
it shows me the msgbox for the click event. I can consistently activate
double-click in the control panel program, however not in macro. I can get
access to the form's double-click event from double-clicking the form.

Have a nice day
John Paul Fullerton
 
I found some code online that allows click and double click

Dim isClick As Boolean

Private Sub Label1_Click()
Dim t As Single
isClick = True
' Wait for the second click for half a second.
t = Timer
Do
DoEvents
' If the DblClick procedure canceled this event,
' bail out.
If Not isClick Then Exit Sub
' The next test accounts for clicks just before midnight.
Loop Until Timer > t + 0.5 Or Timer < t
' Do your single-click processing here.
MsgBox "click"
End Sub

Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
' Cancel any pending click.
isClick = False
' Do your double-click processing here.
MsgBox "double-click"
End Sub

Have a nice day
John Paul Fullerton
 
Back
Top