Cindy M -WordMVP- said:
Hi Dootje,
I'm afraid you don't supply enough information. What kinds of Controls? You
can't simply type controls.Add; something has to precede Controls. Like
CommandBars("Name"). or Me.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail
Cindy,
Thanks for the reply. Here's more info: A user has to enter multiple items
(at least one) that are selected from a predefined table. I want to use a
variable number of comboboxes for this. The reason I don't want to use a
simple
listbox with MultiSelect set to True is that, for each
selected item, the user has to enter two more properties in two textboxes.
At the start, I show one combobox. As soon as an item is selected in the
first combobox, I want the two textboxes to appear, plus a new combobox
below the first one so the user can choose another item. As soon as a
selection is made in the second combobox, two more textboxes plus a third
combobox need to appear, and so on.
Since the number of items the user is going to enter is unknown, I thought
it would be elegant to create the appearing textboxes and comboboxes at
runtime. Of course I could also do this with hidden comboboxes, but then I
would have to define their maximum number at compile time, which I don't
want to do.
I Googled an example that says something like:
<snip>
Public Sub WhatToDoAfterASelectionIsMade(SomeVariable as Long)
Dim MyNewCombobox as ComboBox
...
Set MyNewCombobox = Forms.Controls.Add("VB.Combobox","NewBoxName", Me)
...
End Sub
<\snip>
But I get the error message 'Object does not support this property or
method'
(freely translated from Dutch) at the line starting with Set. And indeed the
object library shows nothing of the sort, so that makes sense. Question is,
how
do I get this method into my project? Or is there another way to achieve
want I
want to do?
Is this enough info for you? I hope you can make chocolate of it (liberally
translated Dutch expression - shouldn't be too hard for a Swiss).
Cheers,
Dootje
(e-mail address removed)