Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable OK command button until checkbox is selected

Status
Not open for further replies.

be17

Technical User
Joined
Feb 7, 2001
Messages
26
Location
US
I would like to make my program have the OK button "disabled" until the user selects one or more checkboxes on the form, at which time it would be enabled. I am new to programming and I don't know what code to use. Any help would be appreciated. Thanks.
 
In Form_Load event put

commandbuttonname.enabled=false

then in check box click event put

commandbuttonname.enabled=True

commandbuttonname should be replaced with your command button name.

Bill Paton
william.paton@ubsw.com

Check out
 
Thank you very much. That's what I was kind of thinking, but I thought I would ask first to save time and hassle. It sounds very easy - I hope it works.
 
That worked great. However, I also have a "Reset" command button on the same form. When the user clicks the "Reset" button it clears and resets all of the checkboxes so that none of them are checked. I would like it to work so that if the user clicks Reset, it will again disable the OK button until they reselect one or more checkboxes. This is the code I currently have (but the OK button remains Enabled, so something isn't working). Any suggestions??

Private Sub cmdReset_Click()

cmdOK.Enabled = False

chkLeftBlank.Value = False
chkNotFor.Value = False
chkInternal.Value = False
chkShred.Value = False
chkOnline.Value = False

End Sub
 
When you set the value of a checkbox it runs the checkbox_click sub. in this sub you set the cmdOK.enabled to true so if you set the cmdOK.enabled = false after setting the check boxes this should fix the problem

-Sean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top