First value in listbox as default

  • Thread starter Thread starter Guest
  • Start date Start date
Igor G. said:
How to set first value in listbox as default value?
Thanks!

Here's untested "air code":

'----- start of example code -----
Dim lngFirstRow As Long

With Me.lstMyListBox
lngFirstRow = Abs(.ColumnHeads)
If .ListCount > lngFirstRow Then
.DefaultValue = _
Chr(34) & .ItemData(lngFirstRow) & Chr(34)
Else
.DefaultValue = ""
End If
End With
'----- end of example code -----

You'd run the code in the form's Load event, probably, and then any time
the list box is requeried.
 
Back
Top