matt09524 Posted October 10, 2005 Posted October 10, 2005 This problem is simple and yet the answer eludes me. I have a custom procedure that I call on the formload. basically if the checkbox is checked, then disable all the buttons, else enable them all. This seems to work when the form loads, it is unchecked. but when I check it again, the buttons are still enabled. I have a similar thing on the main form, except it will constantly check and do what the entire if then statement says. What am I doing wrong? code below Private Sub DefaultCheck() If ckdefault.Checked = True Then emlclr.Enabled = False navclr.Enabled = False sysclr.Enabled = False ctrlclr.Enabled = False frmclr.Enabled = False infoclr.Enabled = False lblbkclr.Enabled = False Else emlclr.Enabled = True navclr.Enabled = True sysclr.Enabled = True ctrlclr.Enabled = True frmclr.Enabled = True infoclr.Enabled = True lblbkclr.Enabled = True End If End Sub I call this sub in the Form_load. Quote
sgt_pinky Posted October 10, 2005 Posted October 10, 2005 When you check your checkbox again, are you sure you are calling this subroutine again? Quote
code Mechanic Posted October 10, 2005 Posted October 10, 2005 This problem is simple and yet the answer eludes me. I have a custom procedure that I call on the formload. basically if the checkbox is checked, then disable all the buttons, else enable them all. This seems to work when the form loads, it is unchecked. but when I check it again, the buttons are still enabled. I have a similar thing on the main form, except it will constantly check and do what the entire if then statement says. What am I doing wrong? code below Private Sub DefaultCheck() If ckdefault.Checked = True Then emlclr.Enabled = False navclr.Enabled = False sysclr.Enabled = False ctrlclr.Enabled = False frmclr.Enabled = False infoclr.Enabled = False lblbkclr.Enabled = False Else emlclr.Enabled = True navclr.Enabled = True sysclr.Enabled = True ctrlclr.Enabled = True frmclr.Enabled = True infoclr.Enabled = True lblbkclr.Enabled = True End If End Sub I call this sub in the Form_load. Hi Are you saying that when you 'Check' the ckdefault checkbox at design time and then run the application that the code fails or when you click the ckdefault check box at run time? If the answer is run time are you calling the 'DefaultCheck' procedure from the CheckChanged event? You could also use less lines of code like this: emlclr.Enabled = Not ckdefault.Checked navclr.Enabled = Not ckdefault.Checked sysclr.Enabled = Not ckdefault.Checked ctrlclr.Enabled = Not ckdefault.Checked frmclr.Enabled = Not ckdefault.Checked infoclr.Enabled = Not ckdefault.Checked lblbkclr.Enabled = Not ckdefault.Checked Cheers CM :rolleyes: Quote
matt09524 Posted October 10, 2005 Author Posted October 10, 2005 At run time, if I change the status of ckdefault it does not execute the conditions. I can see why it's doing this, but I don't see how I can keep the script active without getting myself into a neverending loop or something. What's weird is that I have something like this in another place in my app and i don't have a problem with it :( Quote
*Experts* DiverDan Posted October 10, 2005 *Experts* Posted October 10, 2005 One thought is to either put the DefaultCheck code in the check box's click sub or call the DefaultCheck sub from the check box's click sub as code mechanic suggested. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.