OnClick event sees first click of OnDoubleClick

B

Bob Howard

I have both OnClick and OnDblClick events for a listbox. When the user
double-clicks, the OnClick event fires and then the OnDblClick event fires
right after that. Unfortunately, the OnClick event makes visible some
controls in another portion of the form --- which I really didn't want to
take place during a double-click.

I can make the OnDblClick event hide those controls, but the flash still
draws the user's attention away and is really annoying.

Is there a technique to be able to handle this so that the OnClick event
only fires when it's truly a single click?

I'm using Access 2000.

Thanks folks! I really appreciate this forum!!!!!

Bob (@Martureo.Org)
 
K

Ken Snell [MVP]

To my knowledge, there is no way to "ignore" the first click of a
double-click event... ACCESS will always raise the Click event when you
double-click.

You'll have to revise your design so that it doesn't use both the Click and
Double-Click events for the same object.
 
G

Guest

Could this work? In the double click code, set a global flag indicating the
double click event was running. In the click event, have it wait for .5 to 1
second using DoEvents. If, after this wait, the global flag is not set, then
continue processing.

This will obviously not work if Access won't allow the double click event to
fire while the click event is "waiting."

Regards,
Keith
 
K

Ken Snell [MVP]

I doubt that you'll be successful with that setup....the Click event occurs
first, and its code will begin running immediately. But, the best way to
find out is to try it.

Just a word of caution if it appears to work...timing of overlapping code
runs is tricky and unpredictable, often depending upon what else your PC
might be doing at that time or how quickly a person does an action, or
"unknown" variations.... So, I would never want to depend upon this
situation in a database. Better to find a way to ensure that the two code
groups (Click event's code and Double-Click event's code, whatever you're
doing in them) are run separately under your specific control.

I often will use a command button instead of a Click event (or a
Double-Click event) when I want to allow the user to have some choices. Much
easier then to know exactly what the user wants to do.

--

Ken Snell
<MS ACCESS MVP>
 
B

Bob Howard

Thanks for the suggestion, but bearing in mind Ken's response (and the fact
that I've already run into timing "issues" with this application) I think
I'll just have to find a way to get rid of the OnClick event and handle that
processing another way (possibly using a right-click). Bob.
 
B

Brendan Reynolds

I think that's a wise decision, Bob. Here's an example of how you can use
one command button for different actions. The draw-back to this approach is
that there is no visible cue to the user - the feature is not easily
'discoverable' in UI-designer's terminology. But that is just as true of the
double-click event, so this approach is, if not any better, at least not any
worse in that respect ...

Private Sub Command0_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)

If Button = 1 Then
MsgBox "You clicked the default mouse button"
ElseIf Button = 2 Then
MsgBox "You clicked the other mouse button"
End If

If (Shift And acShiftMask) = acShiftMask Then
MsgBox "You pressed the Shift key"
End If

If (Shift And acCtrlMask) = acCtrlMask Then
MsgBox "You pressed the Control key"
End If

If (Shift And acAltMask) = acAltMask Then
MsgBox "You pressed the Alt key"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top