Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1046
  • Last Modified:

Dynamically add control to form after form is open.

I have seen this question asked several times, and always the answer is NO. But I am stubborn, and come from other environments where it is easy to dynamically add controls.

I hope there is a way (Access 2000) to do this. Please help me find it. This is so important, as I specialize in dynamically growing forms.

Frustrated Fox.
3 Solutions
Yes you can if the form is open in design mode.  Controls can be added only in design mode.  You use the CreateControl Method to do it:
CreateControl(formname, controltype[, section[, parent[, columnname[, left[, top[, width[, height]]]]]]])
And of course, you can open it in design mode:

docmd.openform "formname", acdesign
Leigh PurvisDatabase DeveloperCommented:
Obviously if you deploy mde's though - you can't add controls (as you can't open a form in design mode).
The usual Access workaround is to provide as many hidden controls as could ever be required on the form - setting them a visible and positioned as required.
Admittedly - it's not as nice as spontaneous control arrays - but Access form controls aren't actual windows as in other environments.
Only the control which currently has the focus is a window in a real sense - the rest are effectively "paint on screen" up til that point - which Access uses as a means of keeping system resource use down.
ramromconsultant Author Commented:
Thank you. So sad. All my good work in FoxPro can't be easily ported to Access.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now