two changes required
Private Sub ListBox1_Change()
Dim n As Long
Dim bMatch As Boolean
Select Case Me.ListBox1.ListCount
Case 0
' no processing
Case 1
If Me.ListBox1.List(0) = "Standard/National" Then
Me.Label1.BackColor = vbRed
Else
Me.Label1.BackColor = &H8000000F
End If
Case Else
bMatch = False
With Me.ListBox1
For n = LBound(.List) To UBound(.List)
If .List(n) = "Standard/National" Then
bMatch = True
Exit For
End If
Next n
End With
If bMatch Then
Me.Label1.BackColor = vbRed
Else
Me.Label1.BackColor = &H8000000F
End If
End Select
End Sub
and change this line in listboxp_change
If .ListCount = 1 Then .ListIndex = 0
to
If .ListCount >= 1 Then .ListIndex = 0
Bookmarks