Prevent Over Clicking

jeff_i

Registered User.
Local time
Today, 11:43
Joined
Jan 24, 2003
Messages
50
I have several forms which have command buttons with event procedures for the Double Click event. What I have found is if I click to many times I can cause errors.

After a double click is it possible to deactivate the button so you couldn't acciendtly cause it to run the event again?
 
Jeff,

I haven't heard of this before. It might just be a software
setting on the control panel, much like the adjustable rate
for keyboard repeats.

But you can set a Public variable to some value or make an
invisible control on the form to hold a value. In the ON-click
event on your command buttons:

' ******************************************
If Me.txtInvisibleFlag = "No" Then
Exit Sub
End If

'
' Execute your code
'

'
' Set the flag
'
Me.txtInvisibleFlag = "No"
' *******************************************

This does however have the undesireable side-affect of
only allowing the command button to be used once for each
opening of the form.

hth,
Wayne
 
You can initialize the variable in the Current event. That way the button will be enabled for each record. Then once it is clicked, it is disabled until you move to a new record.
 
Thank you both for your advice!

I found this when I was testing out one of my forms,

I have on my main form a command button which upon being double clicked runs an append query then opens a form which is based upon that table. Well if you over click the code starts twice leading to the append query atempting to run twice, which causes key violations etc. So what I was hoping to do is make the button so its un selectable while the code is running. So basicaly I think WayneRyan's combined with Pat's might do the trick.

Thanks for your help and let me know if the above changes anything...
 
You can disable your command button once it has been clicked (double clicked). Set the Enabled property of the command button to False in the OnClick (OnDblClick) event of your button, run your code (query) and enable the command button at the end of your sub. Please note that you will have to set the focus to another object (button, text box, etc.) for you can not disable an object that has the focus.

Me.SomeObject.SetFocus
Me.CommandButton1.Enabled = False
...run your query here
Me.CommandButton1.Enabled = True

HTH
 
Thanks, this corrects the potential problem

Jeff
 

Users who are viewing this thread

Back
Top Bottom