Finding a control's type

  • Thread starter Thread starter Ron Lounsbury
  • Start date Start date
R

Ron Lounsbury

I have a form that has a series of check boxes, each named chkErr1, chkErr2,
chkErr3, etc. I want a command button to loop through each of the check
boxes and perform an action if the checkbox is checked. I tried the
following code:

Dim thisCtl As Control

For Each thisCtl In Me.Controls
if thisCtl.type = "Checkbox" then
if thisCtl.value = 1 then
ProcessChecked
end if
end if
Next

however, the .type is not a recognized property or method for the Control
type. Can anyone tell me the right way to get only the checkboxes on the
form? I can check the name to see if it starts with "chk", but that seems
to be kludgy.

TIA
Ron Lounsbury
 
"Ron Lounsbury" <rlounsbury AT Progeny DOT net>'s wild
thoughts were released on Wed, 10 Sep 2003 10:18:13 -0400
bearing the following fruit:
I have a form that has a series of check boxes, each named chkErr1, chkErr2,
chkErr3, etc. I want a command button to loop through each of the check
boxes and perform an action if the checkbox is checked. I tried the
following code:


Check out TypeOf and TypeName

J
 
Dim c As Control
For Each c In Controls
If TypeOf c Is CheckBox Then...
Next c

Regards,

Rubén Vigón
Microsoft MVP Visual Basic
 
Jan
Thanks. I'll give it a try.

Ron Lounsbury

Jan Hyde said:
"Ron Lounsbury" <rlounsbury AT Progeny DOT net>'s wild
thoughts were released on Wed, 10 Sep 2003 10:18:13 -0400
bearing the following fruit:



Check out TypeOf and TypeName

J
 
****Untested****
Dim thisCtl As Access.Control
For Each thisCtl In Me.Controls
if thisCtl.ControlType = acCheckbox then
if thisCtl.value <> 0 then
ProcessChecked
end if
end if
Next
****

HTH
Van T. Dinh
MVP (Access)
 
Back
Top