Create controls at run- time

mariadul

Registered User.
Local time
Today, 08:38
Joined
Jun 11, 2003
Messages
11
Hi,
I am trying to create controls (combo boxes) at run time.
I have tried different things ans nothing seams working.

One of the things that I have tried is:

For i = 0 To 10
Load Combo5(i) -> Here I receive an error 'Type mismatch'
next

Mary
 
Last edited:
Have a look at the example posted by ChrisO in this post (four_hundred_rectangles.zip) whereby it creates controls at runtime.
 
Last edited:
The database was empty.........
 
That link was to the most informative Db I have seen for a long time.
It has helped me to progress with this....

Any extra code or code tidying appreciated.:)
Dave
 

Attachments

mariadul said:
The database was empty.........

There's a module in that database. Put the cursor on the code and hit F5.

It tells you, on the thread, that you need to run the code.
 
Thanks,
There is a problem with using CreateControl function it works but you need to create a new form, I need to add controls to an existing form
 
Access says "You can not create controls on an open form, it must be in design view.

I tried the following:

Dim ctlNew As Control

DoCmd.OpenForm "Form1", acDesign
' Create new command button.
Set ctlNew = CreateControl("Form1", acComboBox, , , , 2750, 1900, 1000, 200)
ctlNew.Name = "cboNewCombo"

DoCmd.Close acForm, "Form1", acSaveYes

from a command button on another form where the form I added the controlto was "Form1"

the ctlNew. will set all the properties of the combo box like

ctlNew.RowSource = Select blah blah blah
ctlNew.ColumnWidth = 200

etc

Seemed to work OK

HTH
Dave
 

Users who are viewing this thread

Back
Top Bottom