Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a control to open form

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
Is it possible to dynamically add a control to a form that is open.

I have a form that I want to keep adding combo boxes to after one is filled. I never know how many will need to be created so I don't want to create a ton of them up front and make them invisible. If they need 3 I want to be able to add 3, if they want 20 I want to be able to add 20.

It does not look like you can add controls while a form is open.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
It does not look like you can add controls while a form is open." - it appears to be correct, I'm afraid.

The CreateControl method, requires the form to be in design view.

Just wondering, would using a continuous form, just adding records with combos, so it looks like adding more combo controls, be worth a try?

Roy-Vidar
 
Rats. I am learning Windows Dot Net Forms and thats something I just learned to do there and coicidentally I have an access project that such a dynamic creation of controls at run time would be great.

That other idea raises some curiosity, I will see if I can make it work.

Roy, you da man!

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
You can add controls at design time and make them invisible. At runtime you can make them visible and move them around as needed.
[tt]
Const TWIPS_INCH = 1440

With Me!Text1
.Visible = True
.Top = 2 * TWIPS_INCH
.Left = 1 * TWIPS_INCH
End With
[/tt]

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Thanks VBSlammer, that's what I started doing and sought to see if anyone had overcome the inability to do it at runtime like Dot Net.

I will continue with that approach.

Thanks to both of you. Even though it wassn't what I wanted to here, it's what I needed to hear.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
I dont know how old this is but you must put controls on form @ design time but theres a cheat..

Docmd.Echo false
Call another form and make it invisible
Docmd.close acform,acsaveyes(whatever the exact syntax is)
Call a public sub in this other form that
with put your combo box on the form you called it from
Then in the secind invisible form

docmd.echo true

blah blah..didnt add all step but this will accomplish what you want without it being shown to the user
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top