"P" <P@no_spam.com> wrote in message
news:fc3Ab.9316$aw2.4393101@newssrv26.news.prodigy .com[color=blue]
> Hi,
>
> Access 2002. I created a list box with multiselect set to extended. I
> would like to offer a command button that selects all items for the
> user. I am trying:
> For each varItem in lstAccounts
> lstAccounts.Selected(varItem) = True
> Next varItem
>
> I am getting run-time error 438: Object doesn't support this property
> or method. Any suggestion? Thank you. P.[/color]
'---- start of code ----
Private Sub cmdSelectAll_Click()
Dim lngX As Long
With Me.lstAccounts
For lngX = Abs(.ColumnHeads) To (.ListCount - 1)
.Selected(lngX) = True
Next
End With
End Sub
'---- end of code ----
And our special offer today: code to unselect all!
'---- start of code ----
Private Sub cmdClearSelections_Click()
Dim lngX As Long
With Me.lstAccounts
For lngX = (.ItemsSelected.Count - 1) To 0 Step -1
.Selected(.ItemsSelected(lngX)) = False
Next lngX
End With
End Sub
'---- end of code ----
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)