I don't know if this is possible. I want to use a "Do" loop to run thru a series of controls on my form. The controls are named ctrl1, ctrl2, ctrl3 ... ctrl20 etc. The controls are check boxes. So I am trying to loop thru to determine which ones are "True". I want to use a DO loop to calculate the name of the control, and then look at the value. So far, this is what I have:
Counter = 1
Do While counter < 21
fnCtrl = "ctrl" & Counter ' the 1st time, the control name will be ctrl1
If fnCtrl = True Then
MsgBox("True")
Else
MsgBox("False)
Endif
Counter = Counter + 1
Loop
I want the 1st line after the Do to use the value of fnCtrl as the fieldname to be compared. I want it to be executed as
If ctrl1 = True
But what happens, it is evaluated as
fnCtrl = "ctrl1"
Does anyone have any idea if this can be done.
Counter = 1
Do While counter < 21
fnCtrl = "ctrl" & Counter ' the 1st time, the control name will be ctrl1
If fnCtrl = True Then
MsgBox("True")
Else
MsgBox("False)
Endif
Counter = Counter + 1
Loop
I want the 1st line after the Do to use the value of fnCtrl as the fieldname to be compared. I want it to be executed as
If ctrl1 = True
But what happens, it is evaluated as
fnCtrl = "ctrl1"
Does anyone have any idea if this can be done.