Link to home
Start Free TrialLog in
Avatar of cssc1
cssc1Flag for United States of America

asked on

Why is the code not working to enable and disable command buttons?

I have 30 command buttons on a form and I need to activate or deactivae the each command button depending on the check box selection. I am not a coder but I found some code online and it worked fine for one command button but not for more than one. The code that does not work is:
Private Sub Form_Load()
   If Ctl2 - HumanEngineering = True Then
        Me.Command104.Enabled = True
    ElseIf 2 - HumanEngineering = False Then
         Me.Command104.Enabled = False
    End If



   If Ctl2 - Procedures = True Then
        Me.Command105.Enabled = True
    ElseIf Ctl2 - Procedures = False Then
         Me.Command105.Enabled = False
    End If



   If Ctl2_Work_Direction = True Then
        Me.Command106.Enabled = True
    ElseIf Ctl2_Work_Direction = False Then
         Me.Command106.Enabled = False
    End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cssc1

ASKER

Please see attached image.

What did I do wrong?
CodeError.jpg
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cssc1

ASKER

Please see error.
I think I did things correct????
Error2.jpg
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cssc1

ASKER

Thanks