Is it possible to add Controls during Run-Time with VBA?

id1234

Registered User.
Local time
Today, 09:02
Joined
Apr 9, 2010
Messages
15
Is it possible to add controls to a form in VBA during Run Time in Access 2007?

What I am trying to do is to have a label created for 3 fields (asking a questions) then a grouped set of Radio buttons for the last field. I want to be able to created them on the fly because depending on what the user is doing will determine what and howmany questions are asked.

I am open to suggestions if there is a better way then adding my own controls during Run Time
 
While it is actually possible to create objects on the fly, it is not normally the best practice. The reason is the bloat that you will create in your database when create objects all the time.

Normally you would create all the options you need and then simply make those objects visible or not visible when needed. You can even change the location of objects if needed, so you don't have undesired empty space. There is no excessive overhead to manipulating objects for visible/not visible, enabled/disabled or even moving them around on the screen.
 
Hide the controls until they are needed. Not sure if this would accomplish what you are trying to achieve.
 
It could work to create the objects and hide them however, we are talking a potential of hundreds of controls and I would also have to create/delete controls everytime a questions are added/deleted to/from the database.
 
It could work to create the objects and hide them however, we are talking a potential of hundreds of controls and I would also have to create/delete controls everytime a questions are added/deleted to/from the database.

Then I fear that you should re-examine the process you are using for selections and such. If designed properly, a database can handle adding questions simply by adding them to the table and then things are available on the form withOUT adding additional controls.
 
Oh, and if you really, really want to do it the way you are doing, I would suggest writing the interface in something like VB.NET where you can create controls on the fly.
 
Thank you all for your Help. I think I found another way to display the data in the form without creating additional controls.
 

Users who are viewing this thread

Back
Top Bottom