none
How can I prevent a DoubleClick event from fire twice RRS feed

  • Question

  • Hi

    I run some code started by the On Dbl Click event. Depending on the users clicking this event sometimes fire twice.

    Is it a way to prevent that?


    Cheers // Peter Forss Stockholm

    Thursday, October 17, 2019 6:26 AM

Answers

  • You can set a flag in the module:

    Private DoubleClicked As Boolean

    Then, in the double-click event, only execute if it is False and, when done, set it to True.

    When the code/query has finished, reset the Flag to False.


    Gustav Brock

    • Marked as answer by ForssPeterNova Thursday, October 17, 2019 12:57 PM
    Thursday, October 17, 2019 8:48 AM
  • You cannot.

    But you can evaluate how often you entered your OnDblClick event in what time period.

    btw, what code?

    Cause code in an event is normally executed sequentially. Thus as long as you don't call DoEvents in the event handler, you should be safe.

    • Marked as answer by ForssPeterNova Thursday, October 17, 2019 12:57 PM
    Thursday, October 17, 2019 8:56 AM

All replies

  • It seems that a MsgBox stops it.
    And a messeage to the user is, in my case, positive.

    Are there other ways?


    Cheers // Peter Forss Stockholm

    Thursday, October 17, 2019 6:42 AM
  • You can set a flag in the module:

    Private DoubleClicked As Boolean

    Then, in the double-click event, only execute if it is False and, when done, set it to True.

    When the code/query has finished, reset the Flag to False.


    Gustav Brock

    • Marked as answer by ForssPeterNova Thursday, October 17, 2019 12:57 PM
    Thursday, October 17, 2019 8:48 AM
  • You cannot.

    But you can evaluate how often you entered your OnDblClick event in what time period.

    btw, what code?

    Cause code in an event is normally executed sequentially. Thus as long as you don't call DoEvents in the event handler, you should be safe.

    • Marked as answer by ForssPeterNova Thursday, October 17, 2019 12:57 PM
    Thursday, October 17, 2019 8:56 AM