Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select items in list box at startup 1

Status
Not open for further replies.

ztm

IS-IT--Management
Jul 19, 2001
34
US
How can I have multiple items in a list box selected at startup? I'm using Access 2k. I've built a report generator for a maintenance tracking database. We have about 30 machines listed in a list box that the user can select as many as they want to generate a report for the selected machine (weekly checksheets, repair history, etc.) About a few of them only get selected once in a while whereas the rest are always selected. I'd like to have the ones that are always selected automatically selected at startup, then the user could add to or subtract from those if necessary. Any help would be appreciated.
 
Hi!

Here's is example how to select All list items:

Private Sub pbSelectAll_Click()
Dim i As integer
For i = 0 To Me.lstMyListBox.ListCount - 1
Me.lstMyListBox.Selected(i) = True
Next i
End Sub


You can include in For cycle If statement for selection needed items

Example:
................
................
For i = 0 To Me.lstMyListBox.ListCount - 1
if left(Me.lstMyListBox.column(1),2)="PC" then
Me.lstMyListBox.Selected(i) = True
end if
Next i


Aivars |-0

 
Very nice Aivars,
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top