Items selected from list

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
 
D

Dirk Goldgar

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.
 

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