Seting the listindex doesn't work...

A

AlexT

Folks

I'm most probably doing something stupid but I can't figure it out...

I have a form with various fields from TableA and a combo box whose
data source is a view in a different table.

That view, say qView, returns two fields per record and the combo box
is setup to display two columns, column 2 being hidden (width = 0) and
being the bound column.

Everything works as expected but I don't seem to be able to set the
listindex property of my combo box when loading the form.

I'd like to display the first row of qView in my combo box by default
and use cmbMyBox.listindex = 0 in my code... to no avail. The filed
remains empty... (no value displayed).

What am I missing ?!

Any help welcome

--AlexT
 
K

Ken Sheridan

The ListIndex property is read-only. To select the first row in a combo or
list box you can set the control's value to the value returned by its
ItemData property for row zero. The ItemData property returns the value of
the bound column for the row in question:

cmdMyBox = cmbMyBox.ItemData(0)
 
Top