Dynamically add control to form after form is open.

Posted on 2006-03-19
Last Modified: 2008-02-01
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.
Question by:ramrom
    LVL 39

    Assisted Solution

    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]]]]]]])
    LVL 42

    Assisted Solution

    And of course, you can open it in design mode:

    docmd.openform "formname", acdesign
    LVL 44

    Accepted Solution

    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.
    LVL 17

    Author Comment

    Thank you. So sad. All my good work in FoxPro can't be easily ported to Access.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now