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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox List Bound Hidden select value

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
been away from vba forms for a bit to long, this is driving me mad!

I have an array (var_advisor) that looks like the following

3,A.N,Other
2, Bloggs,Joe
6, Blogss II,Joe
4, John,Doe
7, One,Two
5, Person,Test
8, Problem ,Refresg

I then have a combo box cbo_madvisor


I have set up the combo box with two columns ,
Bound Column property set to 0 ,
Column Count set to 2 .
Textcolumn Set to 1
Column widths set up 0pt,45pt
Match required = True

And my code looks somethign like this

cbo_madvisor.list = var_advisor

All fine and dandy;


However when i try the following code

cbo_madvisor.value = 8 I get a index property value error '380'

If i change the column widths to 30;30 so the first column is not hidden i do not get this error.

It seems to me that when you hide that column , the value switches to teh listindex.

What Am i missing here ?





Chance,

F, G + HH
 
Chance,

When you set the BoundColumn property to zero, the value of the control (ComboBox) becomes the value of ListIndex for the control, not any of the coulumns. You have a combo with 7 entries so that when you try to assign a value to the control (through code) of 8, you are beyond the the legal range of ListIndex.

If you want to assign values through code corresponding to the first values in the array (Col. 1 of the Combo), set the BoundColumn to 1


Hope this helps
Mike
 
Ive tried setting it with one as well, the only problem seems to be when hiding that first column.



Chance,

F, G + HH
 
Chance,

Can you show how you are declaring var_advisor and assigning values to it?


Regards,
Mike
 
var_advisor is coming from a class which is querying a sql server database



Chance,

F, G + HH
 
still cant work out what im missing but
working around it at the moment with the following

Code:
       int_cbo = 0
        Do Until int_cbo = cbo_mplan.ListCount
            If cbo_group.Column(0, int_cbo) = .broker_group Then
                cbo_group.ListIndex = int_cbo
            End If
            int_cbo = int_cbo + 1
        Loop

Chance,

F, G + HH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top