Clicking maniacs…

P

Peter

Hi all..

I have an issue were clicking more then once on a command button creates
problems in a network environment. It takes some time for the command to
reach the back end etc etc. Is it possible to restrict the number of clicks
that execute the command? Lets say that only one “click†is valid..after the
initial click..the command is not valid?

Thanks a lot!
 
L

Linq Adams via AccessMonster.com

You've given us no hints as to what this button does, but as a generic
solution I'd move the focus to another control (preferably a textbox, far
away from the button in question) before running the rest of the code in the
button's OnClick event. This would force the user to return to the button to
click it again.

Alternatively, you could pop up a message box with the first line of code in
the OnClick event, warning the user not to click it again
 
L

Linq Adams via AccessMonster.com

Meant to add, as another alternative, that the "Sister Mary Margaret Steel-
Ruler-to- Knuckles" method is also noted for its effectiveness!
 
M

MikeB

How about just capturing either event...


Private Sub Command0_Click()

'.... Do your stuff here for the Click Event
End Sub

Private Sub Command0_DblClick(Cancel As Integer)
Command0_Click
End Sub
 
T

Tom van Stiphout

On Sun, 8 Nov 2009 03:51:01 -0800, Peter

Yes. In the first line of the button_Click event write:
Me.myButton.Enabled = False
(of course you replace myObjectNames with yours)
and in the last line set it back to True.

-Tom.
Microsoft Access MVP
 
M

Marshall Barton

Peter said:
I have an issue were clicking more then once on a command button creates
problems in a network environment. It takes some time for the command to
reach the back end etc etc. Is it possible to restrict the number of clicks
that execute the command? Lets say that only one “click” is valid..after the
initial click..the command is not valid?

I recommend disabling the button, but that requires the
focus to be moved somewhere else first.
Me.[some other control].SetFocus
Me.[the button].Enabled = False

You may also want to change the cursor to the hourglass:
DoCmd.Hourglass

It's not clear when/where you would want to re-enable the
button, but if you do change the cursor, make sure you
change it baxk when your button's procedure finishes.
 
B

Bob Quintal

Hi all..

I have an issue were clicking more then once on a command button
creates problems in a network environment. It takes some time for
the command to reach the back end etc etc. Is it possible to
restrict the number of clicks that execute the command? Lets say
that only one “click†is valid..after the initial click..the
command is not valid?

Thanks a lot!
In the module's header, define a boolean variable

Dim bWasClicked as boolean

In the form's open event set the variable to False
me bWasClicked = false

In the onClick event

If bWasClicked = true then
exit sub ' ignore the click
Else
'execute your command
me.timer = 5000 ' 5 seconds
me bWasClicked = true
end if
end sub

and in the form's On_timer event
me.timer = 0 ' disable it
me bWasClicked = false
end sub
 
P

Pendragon

In the OnClick property, before you run any code, set the Enabled property of
the button to False. Just remember to set it back to true at some point
(such as when the form has the focus again or is re-opened).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top