[AccessD] How to set the value, not the position, of a combobox

Bill Benson bensonforums at gmail.com
Wed Dec 24 17:22:48 CST 2014


I have an access form with an unbound combo that have been populated via rowsource query such as 

    Select vintageID, Vintage from TblVintage 

I only just noticed a problem with how my control values were being shown when I attempted to set the control to a particular value - thinking that if the bound column is 0, that this was the equivalent value to the combo itself. But apparently that is not so, what is returned (or set) with syntax like

      iVal = cboVintage  <<== returns the ListIndex

    cboVintage = iVal    <<== positions the combo on the ith item (assuming there is one)

I know I can loop through the combo's list, testing until cboVintage.List(i,0) = iVal = true, then set cbovintage.Selected(i) = TRUE. Perhaps this cannot be done because there is no guarantee that there is only one such value in any particular column of the ComboBox. But looping seems expensive, so is there any way to position the combo on the first qualifying item directly?

TIA.





More information about the AccessD mailing list