Can this button be made in a form?

ariansman

Registered User.
Local time
Yesterday, 19:25
Joined
Apr 3, 2012
Messages
157
How can we design a button in a form, so that when it is pressed once, it will be inactivated until the form is open again? Or the button is inactivated for a certain time for example 10 seconds?
 
The following code should allow you to disable the button until the form is closed and re-opened. You need to move the focus to be able to disable it.

Code:
Private Sub yourCommandButton_Click()
  Me.someOtherControl.Setfocus ' move focus somewhere else
  Me.yourCommandButton.Enabled = False
End Sub
 
thank you :)
 
The button can be re-enabled after a period of time by using the OnTimer event of the form.

So part of the coding on the button click event is to set Me.TimerInterval =1000 * 60 * 10 'This is the number of milliseconds in 10 minutes

And in the form's OnTimer event, put

Me.buttonName.enabled = true
Me.TimerInterval =0 'to turn off the OnTimer event
 

Users who are viewing this thread

Back
Top Bottom