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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable / Disable a check box based on 2 other check boxes

Status
Not open for further replies.

starbird

IS-IT--Management
Jun 12, 2002
22
0
0
US
I think I am stuck. Here is what my form set up is.

I have 10 check boxes. The 10th check box, I only want to be enabled if either check box 2 or 7 or both are checked. so, to summarize:
[ul]
[li]If 2 and 7 are both checked, it is enabled, regarless what else is or isn't checked.
[li]If 2 is checked and 7 is not checked, it is enabled, regarless what else is or isn't checked.
[li]If 7 is checked and 2 is not checked, it is enabled, regarless what else is or isn't checked.
[li]If neither 2 nor 7 are checked, it is not enabled, regarless what else is or isn't checked.
[/ul]
What I have working so far. If check box 2 is checked, it is enabled, otherwise, it is not. See my code below (which was taken from another thread, so thank you)
--------------------------------------------
Code:
Private Sub check2_Click()
      If check2.Value = "0" Then
          check10.Enabled = False
      Else
          check10.Enabled = True
      End If
End Sub
--------------------------------------------
Any suggestions?

Thanks
 
Try This

Private Sub Check10_Click()
If IsNull(Check2.Value) Then
Check1.SetFocus
Check10.Enabled = False
Else
Check10.Enabled = True
End If

If IsNull(Check7.Value) Then
Check1.SetFocus
Check10.Enabled = False
Else
Check10.Enabled = True
End If


End Sub
David Lerwill
"If at first you don't succeed go to the pub"
 
Thank you.

Still no luck, it is either never enabled, or always enabled.

should the check1 in the code be check1?
 
I think I got it to work. Here is what I did.

Code:
  Private Sub check2_Click()
      If check2.Value = "-1" Then
          check10.Enabled = True
      Else
        If check7.Value = "-1" Then
          check10.Enabled = True
        Else
          check10.Enabled = False
        End If
      End If
  End Sub

I then did the same for check7, only reversing the check2/check7 order, and it seems to give me what I need. [anakin] YIPPEE!!

Now, on to my next task, having the check clear if it is disabled, but was checked while enabled.

any ideas?[idea]

Thanks again.
 
Hi!

Try this:

Private Sub check2_Click()
If check2.Value + check7.Value = 0 Then
check10.Value = False
check10.Enabled = False
Else
check10.Enabled = True
End If
End Sub

You should be able to use the same code in check7_Click. Alternatively, you can put the code in a separate procedure called from both click events.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top