List box select all

LB79

Registered User.
Local time
Today, 17:21
Joined
Oct 26, 2007
Messages
505
Hello,

Can anyone tell me how to select all items of a list box?

Thanks
 
Thanks - Ive seen this already (spent ages on Google), I cant seem to get it to work which is why I asked here...
My first problem is "Argument no optional" on the Call SelectAll line.
 
This line?

Public Function SelectAll(lst As ListBox) As Boolean

You need to call it using

SelectAll(yourlistboxname) <-changing the name to match your listbox name
 
Thanks Rainman.
When I run the code with that bit done i get a debug on the row "SelectAll = True" saying compile error on left side of assignment must return varient or object.
Do you know what that means?

Thanks

Public Function LstSelectAll(Lst As ListBox) As Boolean
Dim Row As Long
If Lst.MultiSelect Then
For lngRow = 0 To Lst.ListCount - 1
Lst.Selected(Row) = True
Next
SelectAll = True
End If
End Function
 
Of course! I change the name - Access didnt like it for some reason.
OK guys... almost there. I naw have it running, but its only selecting 1 item from the list instead of all items. What else have I done wrong? LOL

Thanks

Public Function LstSelectAll(Lst As ListBox) As Boolean
Dim Row As Long
If Lst.MultiSelect Then
For lngRow = 0 To Lst.ListCount - 1
Lst.Selected(Row) = True
Next
LstSelectAll = True
End If
End Function
 
it should be
Code:
For lngRow = 0 To Lst.ListCount - 1
Lst.Selected([COLOR=Red]lngRow[/COLOR]) = True
Next
LstSelectAll = True
 

Users who are viewing this thread

Back
Top Bottom