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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box with selected items

Status
Not open for further replies.

Cachelot

Programmer
Jan 30, 2001
15
0
0
CA
How can I have a List Box with some of the items already selected?

Here's what I'm doing or trying to do, I have 3 tables, 1 table of people with info on them, 1 table with skills, and the last table is the list of skills for all the people since everyone can have more than one skill. Now what I want is a form with informatioin of one person at a time with list box with all the skills, but with the skills of that person already selected (highlighted) in the list box.

Can someone help me.
 
This is how you select an item in a list box. Suppose you want to select the 3rd item (index starts with 0)

YourListBox.Selected(2) = True
 
Thanks for the info FancyPrairie.

Now I have to figure out some code to loop through the 3rd table to know which one to select.
 
Dim dbs as DAO.Database
Dim rst as DAO.Recordset
Dim i As Integer

Set dbs = CurrentDb
set rst = dbs.OpenRecordset("Select * From YourThird Table Where person = ...")

while not rst.eof
For i = 0 To YourListBox.ListCount - 1
if (rst!YourItem = YourListBox.column(0,i)) then
YourListBox.Selected(i) = True
End If
Next i

rst.MoveNext
Wend
 
Once again Thanks alot for the help and the code FancyPrairie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top