Command buttons in VBA "keep pressing"

Leo_Polla_Psemata

Registered User.
Local time
Today, 14:43
Joined
Mar 24, 2014
Messages
364
Hi,
when user assigns a code to a command button, he has a large amount of options such as
on click
on double click
on got focus
on lost focus
etc.

Could we make an option that
the command is fired when we click and keep pressing it for more than 3 seconds ?
 
what do you mean, you mean triggering the click event while it is being pressed?
look for the property: Auto Repeat = Yes.
 
what do you mean, you mean triggering the click event while it is being pressed?
look for the property: Auto Repeat = Yes.
I mean that, we can either click, or double click. Is there any way we click, keep mouse clicked for an amount of time, say 3 seconds, and if continues clicked 3 seconds the code starts ? I this property: Auto Repeat = Yes. similar ?

My purpose, i have a code that i click (or double click) and update a table, HOWEVER i don't want to set any filters in the table, there is always a risk of click again next day and duplicate all records. Okay, i can get another rule, deactivate button for example iif something , but, a click and keep it pressed for 3' would be safety against wrong click.
 
see this link about autorepeat

so think you would need to set a time on first 'iteration' and compare this time to the current time on each subsequent iteration. If the time is greater than the first time, then run your update code. You would also need something to prevent the update code running again if the button continues to be pressed.

Would think simply disabling the button would be much simpler
 
If you really need to know how long a button is clicked, look at the MouseUp and MouseDown events, though you also have to verify the location of the mouse as being with the rectangle that is the command button. To time the difference between MouseDown and MouseUp, look at the Timer() function, which gives you 60ths of a second resolution.
 

Users who are viewing this thread

Back
Top Bottom