Adding form controls programmatically

  • Thread starter Thread starter Patrick McGuire
  • Start date Start date
P

Patrick McGuire

I have a subform to which I want to add controls at
runtime based on information present in the parent form.
How do I do this? I assumed I would open the form in
design mode and then dimension a control object, set it
to a new control object, define its attributes, and then
add it to the form's controls collection. However, I
don't find an add method in Form.Controls. Am I going
about this the wrong way?

Pat
 
Patrick said:
I have a subform to which I want to add controls at
runtime based on information present in the parent form.
How do I do this? I assumed I would open the form in
design mode and then dimension a control object, set it
to a new control object, define its attributes, and then
add it to the form's controls collection. However, I
don't find an add method in Form.Controls. Am I going
about this the wrong way?


Yes, that is the wrong way. You should never change the
design of a form or report at run time. Big time bloat,
greatly increased exposure to corruption and . . ..

The common approach is to add a sufficient number of
invisible controls at design time. Then make them visible
as needed at run time.
 
Back
Top