View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default filling a combo box with two Columns

Do you know the max size of the database? You can always over size the array
dimensions. It uses more memory, but memory is relatively cheap these days.
The combo box will only display the number of items put into the box. Justt
dim the array at 1000. Are you putting more than 1000 items into the
combobox?

"Jan T." wrote:

Thanx!
Well, now I want to do like your example but I want first to fill the Array
with
values from a db. I dont know how many items it will contain. When using the
Redim Preserve,
I am only allowed to change the Ubound of my Array wich seems to just give
me
more Columns and not more Rows. How do I solve this? Any idea?

Jan




"Norman Jones" skrev i melding
...
Hi Jan,

See The List and Column properties in VBA help.

For example:

'=============
Private Sub UserForm_Initialize()
Dim arr(0 To 4, 1 To 2)
arr(0, 1) = "Dough"
arr(0, 2) = "Petersen"
arr(1, 1) = "Cheap"
arr(1, 2) = "Hawley"
arr(2, 1) = "Bill"
arr(2, 2) = "Smith"
arr(3, 1) = "Bruce"
arr(3, 2) = "Jones"
arr(4, 1) = "Bob"
arr(4, 2) = "Copeland"

With Me.ComboBox1
.ColumnCount = 2
.List = arr
End With
End Sub
'<<=============


---
Regards,
Norman


"Jan T." wrote in message
...
Hi.
How can I fill a Combo Box with two Columns?
Using ComboBox1.AddItem seems to only accept one column?

This is what I want the Combo Box to contain:
1 Dough Petersen
2 Cheap Hawley
3 Bill Smith
4 Bruce Jones
5 Bob Copeland

Using the Additem method of the Combo Box, it seems like I can only have
one column? How can I have several columns?

Thanks for your help in advanse.

Regards
Jan