Checking for Null Value in ListBox

D

Dave

I need some help on probably on something relatively simple.
I am trying to guarentee that something has been selected in a listbox
before the user can continue. I am checking a simple multselect,multicolumn
listbox . The problem I have is if a user selects an item, then unselects
the item the NULL check does not work. How do I make sure that a selection
has been made. This is what I tried.

If IsNull(Me.List3.Column(1)) Then

DoCmd.OpenForm "ContractandQuater" (form displays must select something)

Exit Sub
End If

Thanks in Advance,
 
A

Allen Browne

Use IsNull() if it is *not* a multi-select list box.
Use ItemsSelected.Count if it is a multiselect.

Aircode:

Function IsSomethingSelected(lst As Listbox) As Boolean
If lst.MultiSelect = 0 Then
IsSomethingSelected = Not IsNull(lst)
Else
IsSomethingSelected = (lst.ItemsSelected.Count > 0)
End If
End Function
 
Top