listindex and itemdata
Posted on 2001-07-31
I am loading a combobox using the following code
Do Until rsData.EOF
cboFloor.AddItem rsData("DESC_Floor").Value & ""
cboFloor.ItemData(cboFloor.NewIndex) = rsData("PKID_Floor").Value & ""
In this case it loads the floors of a building and the combobox would contain the following data:
ListIndex List ItemData
0 First Floor 111
1 Second Floor 112
2 Third Floor 113
The combobox data loads without a problem. However, in some cases I have a floor preselected. In these cases I want the combobox to load completely and to have that floor selected by the program. This is easily done with "cboFloor.ListIndex = mi_ListIndex" but the data I have is the ItemData. How can I convert the ItemData number (which I have) to the corresponding ListIndex number (which I need to make this work).