Solved Dblclick a command button?

Gasman

Enthusiastic Amateur
Local time
Today, 21:06
Joined
Sep 21, 2011
Messages
16,891
A member on another site is trying to avoid any double click on a button being transferred to the subsequent form that button is opening?

This made me wonder, Why is there a double click event for a button?
I have used the event for textbox controls several times, but never occurred to me to use it for a button?

Has anyone here ever done that? and for what particular reason?
 
In my reply, I questioned whether it is in fact a double-click event. The OP wasn't very clear on that point. I think what may be happening is that the second or third click is inadvertent. And I suspect that what is really happening is the command button on the subsequent form is actually receiving those additional clicks, triggering their code.

However, that is just my guess and subject to verification.
 
In my reply, I questioned whether it is in fact a double-click event. The OP wasn't very clear on that point. I think what may be happening is that the second or third click is inadvertent. And I suspect that what is really happening is the command button on the subsequent form is actually receiving those additional clicks, triggering their code.

However, that is just my guess and subject to verification.
Yes George, that was what he was complaining about. Try it on the DB yourself. I found just trying on Form B, that having another control, stopped that, as any subsequent clicks were applied to that control? So as long as there is no code on that control for click/dblclick, or empty events?, then that would fix the problem.

However a dblclick event exists for a command button? :)
 
Why is there a double click event for a button?

Probably because the mechanism for double-click "rides" ALL items that have clicks. Although I've never actually looked, every clickable item I've ever worked with allowed the double-click. Which means that, probably, the enabling of double-click is part of an "all or nothing at all" feature. Just like .OldValue and .DefaultValue are part of the all-or-nothing baggage of a control being bound to a field.
 
Yes George, that was what he was complaining about. Try it on the DB yourself. I found just trying on Form B, that having another control, stopped that, as any subsequent clicks were applied to that control? So as long as there is no code on that control for click/dblclick, or empty events?, then that would fix the problem.

However a dblclick event exists for a command button? :)
To be honest, I thought that was the case as well, but I've learned not to leap to conclusions when interpreting questions posted in public forums. It's more work for me to walk back from an unnecessary leap than to toddle along from question to question.

I think the double-click event on a command button is sketchy, but it is available, presumably for the reason Doc Man said.
 
not really sure I understand the issue that the user experiences but this may be an issue of the calling form or this form having a command button with default set to yes
 
I *think* it is because the subsequently opened form has it's button in the exact same place (at least the test db does) and any second click is being applied to that button. They are also opening the form in exactly the same place.

Here is the DB.
 

Attachments

Is this an academic exercise or the OP really wants to do this? Seems silly at best.

The order of events is
Double-clicking a control causes both the Click and DblClick events to occur. For example, when you double-click a control other than a command button, the following sequence of events occurs for the control:

MouseD own
arrow
MouseUp
arrow
Click
arrow
DblClick
arrow
MouseUp
So if you double click you also click first.

Here is my understanding why the command button has a double click. It is because it can be canceled and the click event cannot be canceled.

Imagine you have a click event that does an insert query each time it is clicked. Assuming you had no double click event procedure. If a user came in and mistakenly double clicked it by accident it may actually do two individual click events and submit the record twice. If you include the Double click event you can cancel it.

Since the double click happens before a second regular click this will keep your user from submitting the record twice. Although I probably write code so they cannot submit the record twice.
Code:
Private Sub btnContinue_DblClick(Cancel As Integer)
    Cancel = True   
End Su

Cannot say I have needed to do this. But I think having the double click is more about using either the double click or the click event but not both. Any time you fire multiple events off a single user action it gets really hard to code around the events.

To me this is the old joke "hey Doc it hurts when I do this." So do not do it. Not sure what the OP wants to really accomplish, but probably a lot smarter ways to do it.
 
Oh, they really want to do this.:)
Seems they have clumsy users. :(
 
If you want to watch events live, as they happen, you can import the forms into this database and put the single line of logging code in each event you want to monitor. I suggest watching at least one of the videos so you get an understanding of how the logging form works.

 
Oh, they really want to do this.
If they really wanted to do this put a timer on the second form load event and only enable the button after a set period of time. probably less that a half second. Works for me.
Code:
Private Sub Form_Load()
  Me.btnContinue.Enabled = False
  Pause 0.5
  Me.btnContinue.Enabled = True
End Sub


Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Err_Pause

    Dim PauseTime As Variant, start As Variant

    PauseTime = NumberOfSeconds
    start = Timer
    Do While Timer < start + PauseTime
    DoEvents
    Loop

Exit_Pause:
    Exit Function

Err_Pause:
    MsgBox Err.Number & " - " & Err.Description, vbCritical, "Pause()"
    Resume Exit_Pause

End Function
 
That has been offered.
O/P went with hiding subsequent form for a few milliseconds in à form timer, before displaying that form.
 

Users who are viewing this thread

Back
Top Bottom