Hold button down

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

I would like an event to fire once at a button click - but
if I keep pressing the button (dont release the mouse) I
would like it to repeat.

How do I make it do that?
 
Rick said:
I would like an event to fire once at a button click - but
if I keep pressing the button (dont release the mouse) I
would like it to repeat.

How do I make it do that?

You could create a module level boolean variable (e.g. mfRepeating). Then,
in the MouseDown event, do this:

mfRepeating = True
Do While mfRepeating
'Do some repeating stuff here
DoEvents
Loop

In the MouseUp event, do this:

mfRepeating = False


This will run the loop as fast as the computer will permit. For more
control over the speed of the repetition, you could put the repeating code
in the form's Timer event. Start the timer, with an appropriate interval,
in the MouseDown event, and stop it in the MouseUp event.
 
I would like an event to fire once at a button click - but
if I keep pressing the button (dont release the mouse) I
would like it to repeat.

How do I make it do that?

Set the Command button's AutoRepeat property to Yes.
It's on the property sheets Other tab.
Note: Copied from Access Help...

"If the code attached to the command button causes the current record
to change, the AutoRepeat property has no effect.

If the code attached to the command button causes changes to another
control on a form, use the DoEvents function to ensure proper screen
updating."
 
Back
Top