Control Limit

  • Thread starter Thread starter Richard Grene
  • Start date Start date
R

Richard Grene

When looping through controls on a form, there seems to be a limit of 57,
even though there are 75 on the form. This is the code:
Dim sControl As Control

For Each sControl In Me.Controls

next sControl

I looked at the Forms designer Generated Code and me.Controls.AddRange only
contains 57 out of the 75 controls.

Any ideas.

Thanks,
Richard
 
Richard Grene said:
When looping through controls on a form, there seems to be a limit of 57,
even though there are 75 on the form. This is the code:
Dim sControl As Control

For Each sControl In Me.Controls

next sControl

I looked at the Forms designer Generated Code and me.Controls.AddRange only
contains 57 out of the 75 controls.

This code will only enumerate the controls which are placed directly
onto the form, not the controls nested inside containers.
 
Hi, You're seeing this because you have controls as part of other controls,
e.g. checkboxes within a group box, or buttons in a panel (or of course
anything else where there are child controls in a parent control). If this
is the case, you need to perform a recursive search, which searches for
child controls within controls.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"


: When looping through controls on a form, there seems to be a limit of 57,
: even though there are 75 on the form. This is the code:
: Dim sControl As Control
:
: For Each sControl In Me.Controls
:
: next sControl
:
: I looked at the Forms designer Generated Code and me.Controls.AddRange
only
: contains 57 out of the 75 controls.
:
: Any ideas.
:
: Thanks,
: Richard
:
:
:
:
 
Hi Richard,

If any of the Controls are contained within another Control, eg a Panel,
they will be in the Controls collection of the Panel rather than of the Form.

Regards,
Fergus
 
Back
Top