H
hkgary33 via AccessMonster.com
Dear all,
In one of my form, I’ve created 20 check boxes c1,c2…c20 (these checkboxes
are not grouped), and a OK button and Cancel button. Now I’m interested in
which checkboxes the user ticked. So I’ve written a click event procedure for
the OK button. But it’s a mess if I check the value of each checkbox one by
one using the following if statement:
If c1 = True Then
…
End If
If c2 = True Then
…
End If
…
Now what I’d like to do is to use a loop instead of using 20 If…Then
statements, just like the following:
For counter = 1 To 20
temp = “c” & CStr(counter) ‘reconstruct the combo box names
If Me.temp = True Then
…
End If
Next
But it doesn’t work becuz it can’t detect my variable names…so what can I do
to solve this problem? Do I really need to use the first clumsy method to do
it?
Thanks so much!
Gary
In one of my form, I’ve created 20 check boxes c1,c2…c20 (these checkboxes
are not grouped), and a OK button and Cancel button. Now I’m interested in
which checkboxes the user ticked. So I’ve written a click event procedure for
the OK button. But it’s a mess if I check the value of each checkbox one by
one using the following if statement:
If c1 = True Then
…
End If
If c2 = True Then
…
End If
…
Now what I’d like to do is to use a loop instead of using 20 If…Then
statements, just like the following:
For counter = 1 To 20
temp = “c” & CStr(counter) ‘reconstruct the combo box names
If Me.temp = True Then
…
End If
Next
But it doesn’t work becuz it can’t detect my variable names…so what can I do
to solve this problem? Do I really need to use the first clumsy method to do
it?
Thanks so much!
Gary