Hi everyone,
This is something I've struggled with for a long time. It's proving quite difficult to google so I've come here.
I have a form with countless checkboxes, all neatly named (Checkbox1, Checkbox2 etc).
A subroutine loads this form and assigns values (i.e. true/false) to these checkboxes before showing it, based on various conditions. However it is immensely wasteful to put an "IF THEN" line of code for each and every one... is there a way I can loop through them, using the pattern in their control names? Can it be done for variables?
Thanks!
Here's a (very) simplified example of my code:
And here is an example of what I'm trying to do (except obviously this code doesn't work):
This is something I've struggled with for a long time. It's proving quite difficult to google so I've come here.
I have a form with countless checkboxes, all neatly named (Checkbox1, Checkbox2 etc).
A subroutine loads this form and assigns values (i.e. true/false) to these checkboxes before showing it, based on various conditions. However it is immensely wasteful to put an "IF THEN" line of code for each and every one... is there a way I can loop through them, using the pattern in their control names? Can it be done for variables?
Thanks!
Here's a (very) simplified example of my code:
Code:
If integer1 = 7 then .Checkbox1 = True
If integer2 = 7 then .Checkbox2 = True
If integer3 = 7 then .Checkbox3 = True
If integer4 = 7 then .Checkbox4 = True
And here is an example of what I'm trying to do (except obviously this code doesn't work):
Code:
For i = 1 To 4
If integer & i = 7 then .Checkbox & i = True
Next i