Adding form controls programmatically

  • Thread starter Patrick McGuire
  • 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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top