How to cycle throught controls in a form....?

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I have 20 unbound check box controls in a form which represent 20 fields in
a table. I want to assign an "After Update" event to each of the control so
that when the user check off the control and it will construct the "Select"
clause of the SQL string. Also I have a combo box with the "RowSourceType"
set to "Value List" and those fields got checked off that will become the
"RoeSource" of that combo box. A text box will allow user to type in the
"Criteria" and the value will be used to construct the "Where" clause of the
SQL string. I have a hard time just to loop through the 20 unbound check box
controls to determine if it is included to construct the "Select" clause,
not to mention how to construct the "Where" clause of the SQL string.
Thanks.
 
Paul said:
I have 20 unbound check box controls in a form which represent 20
fields in a table. I want to assign an "After Update" event to each
of the control so that when the user check off the control and it
will construct the "Select" clause of the SQL string. Also I have a
combo box with the "RowSourceType" set to "Value List" and those
fields got checked off that will become the "RoeSource" of that combo
box. A text box will allow user to type in the "Criteria" and the
value will be used to construct the "Where" clause of the SQL string.
I have a hard time just to loop through the 20 unbound check box
controls to determine if it is included to construct the "Select"
clause, not to mention how to construct the "Where" clause of the SQL
string. Thanks.

I'm not sure what you're trying to do, but if you give all your
checkboxes the same base name but a consecutive numeric suffix, like
chkCheck1, chkCheck2, ... Check20, then you can use a loop like this:

Dim i As Integer

For i = 1 to 20
With Me.Controls("chkCheck" & i)

If .Value = True Then
' ... do something ...
Else
' ... do something else ...
End If

End With
 
Back
Top