Creating a control on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create controls programmatically on an existing form. The
User will select certain values in list boxes, and based on these values,
some number of additional boxes will be created. I need to switch to design
view to add the controls. Can I swith the view programmatically, or do I
have to close the form, and reopen it in design view....
 
I would like to create controls programmatically on an existing form. The
User will select certain values in list boxes, and based on these values,
some number of additional boxes will be created. I need to switch to design
view to add the controls. Can I swith the view programmatically, or do I
have to close the form, and reopen it in design view....

There is an absolute maximum number of controls (754) that can be
added to a form over it's lifetime. Deleting some does not affect that
number.

See Access Help + Specifications + access Specifications + Forms and
Reports.

You would be better off adding all the necessary controls once, and
making them Visible or Not Visible as needed.
 
Great advice, thanks.
How about if I programmatically create a new form with the controls, which
will be destroyed on closing? This way, I won't have to worry about the
lifetime of the form.
 
Use fredg's advice. You are asking for database bloat to do it that way and
it will be slow.
 
Wavequation said:
I would like to create controls programmatically on an existing form. The
User will select certain values in list boxes, and based on these values,
some number of additional boxes will be created. I need to switch to design
view to add the controls. Can I swith the view programmatically, or do I
have to close the form, and reopen it in design view....


No, NO, Don't think of that as a way to do anything.
Modifying the design of heavy duty objects can cause all
kinds of nasty problems.

Instead, pre-create a bunch of the appropriate type controls
and make them visible as needed.
 
In addition to the other responses you have received, keep in mind that
doing as you suggest would limit your app to users with the retail version
of Access. Design view simply isn't available in Runtime mode, even
programatically.

This may not be an issue now, but could become one if your app is a big
success :-)

HTH,
 
Back
Top