Two ComboBox Questions

D

DGjr.

Hi folks. Can anyone help me -- I'm designing a template, and have two
questions:

1. Can I have several ComboBoxes show the same drop down list without
needing to list the items (additem) for each seperate control? I have several
rows that will need to show a copy of the same dropdown list.

2. Where do I populate the combo box in my form? I'm currently coding it in
"Private Sub Document_New ( ). Is this correct?

Thanks!!!!

DGjr.
 
D

David Sisson

2. Where do I populate the combo box in my form?
Array to Listbox or combobox
http://word.mvps.org/faqs/userforms/LoadListBoxIntoArray.htm
I'm currently coding it in
"Private Sub Document_New ( ). Is this correct?

If you're using a template. If you're using a Doc, use
document_open().
1. Can I have several ComboBoxes show the same drop down list without
needing to list the items (additem) for each seperate control? I have several
rows that will need to show a copy of the same dropdown list.

You'll have to create a different combobox on each page(location), but
you can assign the same array to each using the technique in the link.

David
 
D

DGjr.

David -

Sorry to be thickheaded, but could you give me an example? I read the doc
you suggested, but am still unclear. Assuming I have the following list for
ComboBox1, how do I assign that list to "myarray" and then how do I have
ComboBox2 equal that array? Perhaps I am unclear on how ComboBox1.List ( )
=myArray works.

I really appreciate the help!

ComboBox1.AddItem " "
ComboBox1.AddItem "one"
ComboBox1.AddItem "two"
ComboBox1.AddItem "three"

DGjr.
 
D

David Sisson

I assumed your items in the list were already in an array.

If you're adding each item to ComboBox1, and you want to add those same
items to ComboBox2, you could simply copy the additems code and change
the 1 to a 2. I'm not sure if you can Combobox1.list = ComboBox2.list.
But you could, using the example in the link,

ComboBox1.AddItem " "
ComboBox1.AddItem "one"
ComboBox1.AddItem "two"
ComboBox1.AddItem "three"

MyArray = ComboBox1.list
ComboBox2.list = MyArray

But since the List to Array creates a two dimensionally array, it might
be more trouble than it's worth.

If you only have a handfull of items in your list, you could...

DIm MyArray(9) as String ' Ten items (The first one is 0)

MyArray(0) = " "
MyArray(1) = "One"
MyArray(2) = "Two"
MyArray(3) = "Three"

ComboBox1.list = MyArray
ComboBox2.list = MyArray

....rest of you code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top