I am making an improved version of a userform I got working earlier. The purpose of it is to select business data from a certain period per account in our system, and basically I have this part already working.
Now I find myself lost with something that is probably simple, but I don't know whats wrong.
So on the userform, I have two buttons. The first is labeled "Unselect All Months" and it sets the value of 12 checkboxes (which are named after months) to FALSE. So basically it's an on click event like this
Private Sub UnselectAllMonths_Button_click()
Dim j As Integer
For j = 0 To TimeAndSubForm.TimePeriodFrame.Controls.Count - 1
TimeAndSubForm.TimePeriodFrame.Controls(j).Value = "False"
Next j
End Sub
Then I have another button, which is supposed to do the opposite and set the value TRUE for all those checkboxes. Only it doesn't. It does the exact same thing as the above script, and here's how it looks.
Private Sub SelectAllMonths_Button_Click()
Dim j As Integer
For j = 0 To TimeAndSubForm.TimePeriodFrame.Controls.Count - 1
TimeAndSubForm.TimePeriodFrame.Controls(j).Value = "True"
Next j
End Sub
What am I doing wrong here?
If I would write the code without the variable j I get what I want and the checkboxes will be checked as I click the button.
TimeAndSubForm.TimePeriodFrame.Controls(0).Value = "True"
TimeAndSubForm.TimePeriodFrame.Controls(1).Value = "True"
'etc
That's basically it.
Aucun commentaire:
Enregistrer un commentaire