Items selected from list

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi

How can I know if any items is selected from a list

I want at least one item other wise the query will not be
executed

Thanks
 
Chris said:
Hi

How can I know if any items is selected from a list

I want at least one item other wise the query will not be
executed

Thanks

In an Access list box control, you mean? If its Multiselect property is
set to None, you can just check if the list box's value is Null:

If IsNull(Me!lstMyListBox) Then
' nothing is selected
End If

If it's a multiselect list box, though, you must check the ItemsSelected
collection:

If Me!lstMyListBox.ItemsSelected.Count = 0 Then
' nothing is selected
End If

Note that you can still test the ItemsSelected collection even if the
list box is not set for multiselect; it's just simpler to test the
value in such a case.
 
Back
Top