Disable abutton on the form.

2 replies [Last post]
User offline. Last seen 2 years 2 days ago. Offline
Joined: 02/02/2010
Posts: 2

Hello ,

I am trying to disable a button on the form. I cant see any event like click, or id of the button on the form.All i am doing is assigning a macro to the button which takes care of uploading data in the sql database.

Once data is uploaded, i want to disable the button so that user cant click on it again by mistake.

Also, data i am uploading is,contains records of multiple data i.e. a number of rows contain same data in each filed.Tnere is no clean way to differentiate one row than the other.

Is there a way that i could stop user uploading the same data twice,coz user could copy the form and could upload the same data again even if i have disabled the button on the form after first successfull upload.

Any suggestions....

 

User offline. Last seen 2 years 2 days ago. Offline
Joined: 02/02/2010
Posts: 2
Thanks For your reply. The

Thanks For your reply.

The button i am using on the form is not a command button, coz i can't see the click event. If i right click on it, it has got option like, cut,copy,paste,exit edit text grouping,order,assign macro,format control. I cant see anywhere click event.

In VBA code,i created a macro,assigned it to the button and thats it.

User offline. Last seen 3 weeks 6 days ago. Offline
Joined: 06/02/2008
Posts: 15
Diable Command Button

Hi,

Every button on a Userform in excel is an object that belongs to the userform. The command button object in the form has its own properties and methods. One of the property you woul want to use is the "enabled" property.

So, here is how you do it...

Assuming your form is "Userform1", Your Button name is "CommandButton1"

In the design mode of the userform double click the CommandButton1, this will take you to the code which will run as soon as the CommandButton1 is clicked.

The following code will run as soon as the button is clicked, and the first thing you want to do here is to disable the CommanButton1 using "CommandButton1.Enabled = False"

This will ensure that users after a click will not be able to click the button again.

......................................

Private Sub CommandButton1_Click()

'Disable the CommandButton1

CommandButton1.Enabled = False

'Now do your stuff

End Sub

.......................................

 

I hope this helps. Let me know.

Richard