I am trying to running the following code, to select the list box value where there is only one item in the list. However I keep getting the error "7777 You've used the ListIndex property incorrectly". I have observed the following points.
1. I have SetFocus to the control that I have tried set the value for.
2. I have tried to use the selListBox.Selected(0) method, but keep getting the "Object deosn't support this property or method"
3. The selListBox is passed as a variant because it is passed from a collection. I have changed this to selListBox as ListBox - but the same error occurs.
4. Although the error message ""7777 You've used the ListIndex property incorrectly" occurs, the correct list box item does get selected.
I am using Access 2003. Any suggestions? Thanks
Function SelectOneListItem(selListBox As Variant)
If selListBox.ListIndex = -1 Then
If selListBox.ListCount = 1 Then selListBox.SetFocus: selListBox.ListIndex = 0: selListBox.Selected(0) = True