Please Help?! Selected function

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

Guest

Good Morning,

I am having trouble with the '.selected' function in VB, I don't think i'm
using it right.

I want a message to be displayed, after a command button has been clicked,
if any row in a list box hasn't been selected. I'm not sure how to set it up
properly, i am currently using this:

Where 'Care_Points' is the list box

If (Me.Care_Points.Selected(X) = False) Then
MsgBox "Click on Care Point.", vbInformation + vbOKOnly, _
"Select Care Point"
End
End If

Thanx in advance
 
If you want something to happen when *any* row is unselected (i.e. you want
it to happen unless all rows are selected) then the simplest solution is
probably to compare the ListCount property with the Count property of the
ItemsSelected collection. If the two don't match, then at least one item is
unselected ...

Private Sub Command2_Click()

If Me.List0.ItemsSelected.Count <> Me.List0.ListCount Then
MsgBox "One or more items are unselected."
End If

End Sub
 
I want it to happen when all rows are unselected, my list box doesn't support
multiple selections....

Thanx
--
Regards

Ashley Smart


Brendan Reynolds said:
If you want something to happen when *any* row is unselected (i.e. you want
it to happen unless all rows are selected) then the simplest solution is
probably to compare the ListCount property with the Count property of the
ItemsSelected collection. If the two don't match, then at least one item is
unselected ...

Private Sub Command2_Click()

If Me.List0.ItemsSelected.Count <> Me.List0.ListCount Then
MsgBox "One or more items are unselected."
End If

End Sub
 
Are you saying that you're not providing a value for X in the statement

If (Me.Care_Points.Selected(X) = False) Then

?

Are you simply trying to determine whether or not any row has been selected?

Try

If (Me.Care_Points.ItemsSelected.Count = 0) Then


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


A. Smart said:
I want it to happen when all rows are unselected, my list box doesn't support
multiple selections....

Thanx
 

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