First value in listbox as default

D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top