Clicking maniacs…

  • Thread starter Thread starter Peter
  • Start date Start date
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!
 
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
 
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
 
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.
 
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
 
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).
 
Back
Top