Click v Double Click (1 Viewer)

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
I have, or rather had, both a click and double click events on a sub form in datasheet view. On their own, each performed their task as expected. However, when both were enabled at the same time, the Click event was firing in preference to the double click event firing. My understanding is click speed is controlled at system level. So I'm a bit perplexed as to what is causing this behaviour.

Has anyone else come across this? If so what was your solution?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 12:05
Joined
Jul 9, 2003
Messages
16,245
You might find a hotkey a better solution. See video number 4 on my website here:-

 

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
Very nice 👍 I think that will fill the bill nicely :)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 12:05
Joined
Jul 9, 2003
Messages
16,245
Very nice 👍 I think that will fill the bill nicely :)

If you would like a free copy of the sample database, contact me in a private message and I will explain how you can get a free copy.
 

Minty

AWF VIP
Local time
Today, 12:05
Joined
Jul 26, 2013
Messages
10,355
@LanaR - In Access a click event is always fired regardless of the secondary "double" click happening.
Because of that, they are in real use mutually exclusive.

Personally, I tend to use Double Click to fire events on anything except a command button, as it seems more intuitive to me. (e.g. a reference number in a continuous form list to open a detail form or pop-up)
 

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
@Minty I didn't realise Access had that behaviour. Normally I'd just use the double click event, as you suggest, but in this situation I wanted a second option, and figured like most other applications Access could discriminate between a click and a double click
 

Mike Krailo

Well-known member
Local time
Today, 08:05
Joined
Mar 28, 2020
Messages
1,030
I didn't look at Uncles video yet but I usually use a mouse down event on a button or whatever control to get two different subs to fire. For instance, Ctrl-Click on the button to get the mouse down event to fire. What's really interesting is that if you put a click event on a label and use a double click on that same label, it fires both events no problem! It won't do that on a button though.

Code:
Private Sub RunBtn_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Shift = 2 Then
      DoCmd.OpenForm "MyOtherForm"
   End If
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 19, 2002
Messages
42,981
What action are you trying to identify? Perhaps the GotFocus event would work for the Click.
 

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
What action are you trying to identify? Perhaps the GotFocus event would work for the Click.
The click function opens an information form, whilst the double click runs an update query. I believe that both @Uncle Gizmo and @Mike Krailo solutions will fit the bill. I've not yet compared the two options as I only downloaded UG's DB just before I went to bed last night.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 12:05
Joined
Feb 19, 2013
Messages
16,555
you could consider using the mouse down or up events for your click event - they have a shift parameter so if 1 the the dosomething (user is holding down the shft key)

Private Sub Text0_DblClick(Cancel As Integer)
Debug.Print "dc"
End Sub

Private Sub Text0_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Shift = 1 Then Debug.Print "MU"
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 19, 2002
Messages
42,981
I question the running of an update query based on a double-click. Sounds like there is something wrong with the schema that is causing you to store calculated values.
 

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
@Pat Hartman I believe that the schema is fine. However, your comment has caused me to go back and look at what is going on, and I do believe that there may be other ways of achieving what I'm doing without running the query, which I will explore shortly. Thanks for the prod :)
 

LanaR

Member
Local time
Today, 23:05
Joined
May 20, 2021
Messages
113
If there is a way of overcomplicating something, I'll unusually find it
HeadBang.gif
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 19, 2002
Messages
42,981
Always happy t unwind something overly complicated:) especially when I didn't even have to see it:)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 19, 2002
Messages
42,981
Let's not fight children. I probably have more experience at making mistakes than both of you combined which is why I don't even have to see one to recognize it:)
 

Users who are viewing this thread

Top Bottom