Checking for Null Value in ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
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
 

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

Back
Top