Eljefegeneo
Still trying to learn
- Local time
- Yesterday, 17:19
- Joined
- Jan 10, 2011
- Messages
- 904
I am trying to prevent the user from checking a second checkbox when another is checked. I have five days listed, Day1, Day2, Day3, Day4 and Day5. They are selected from a list of days (or combination thereof) of days of the week. But we need only to be concerned with Sun, Mon, Tue, Wed, Thu, Fri, Sat.
They have a corresponding check boxBP2, BP3, etc.
Then I have a second set of seven checkboxes to update the number of times a day appears in a certain month. They are cb1, cb2, etc.
What I have written is as follows:
I have done this for each of the seven set of checkboxes, altering the code to the day of the week.
The problem arises when I have Day2 as Mon ticked in the first set of checkboxes and have the corresponding check box BP2 ticked, but Day3 may be listed as "Tue", then when I click on cb3 which corresponds to Tuesday, it tells me that this is also a bonus day.
I realize that I do not have the correct syntax in the IF statement, but after two hours of trying all kinds of alternatives, I cannot see the trees because of the forest.
They have a corresponding check boxBP2, BP3, etc.
Then I have a second set of seven checkboxes to update the number of times a day appears in a certain month. They are cb1, cb2, etc.
What I have written is as follows:
Code:
Private Sub cb1_Click()
'Prevents the day from being used in a calculation
If (BP2 = True Or BP3 = True Or BP4 = True Or BP5 = True) And (Day2 = "Sun" Or Day3 = "Sun" Or Day4 = "Sun" Or Day5 = "Sun") Then
cb1 = False
MsgBox "This is a bonus day!"
End If
End Sub
The problem arises when I have Day2 as Mon ticked in the first set of checkboxes and have the corresponding check box BP2 ticked, but Day3 may be listed as "Tue", then when I click on cb3 which corresponds to Tuesday, it tells me that this is also a bonus day.
I realize that I do not have the correct syntax in the IF statement, but after two hours of trying all kinds of alternatives, I cannot see the trees because of the forest.