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!

Loading List box

Status
Not open for further replies.

savok

Technical User
Jan 11, 2001
303
0
0
AT
Hi I am trying to load a list box with a Field and an Id

And need to later extract that ID.

Heres what I got so far

If Not objRec.EOF Then objRec.MoveFirst
Do While Not objRec.EOF
lstTitles.AddItem objRec!Job_Title
lstTitles.ItemData(lstTitles.NewIndex) = objRec!titleid
objRec.MoveNext
Loop

This adds the Job Title and TitleID as index I assume?

What I need to do is extract that titleid when the list box is clicked upon. Can anyone post the correct syntax plz. Thanks.

I tried these but it did not work, perhaps I am loading the index wrong? Any help would be great ;)

MsgBox (lstTitles.ItemData(Index))
MsgBox (lstTitles.Index)


 
plz ;) really need the syntax for this, dont have my book with me lol

 
If Not objRec.EOF Then objRec.MoveFirst
Do While Not objRec.EOF
lstTitles.AddItem objRec!Job_Title
lstTitles.ItemData(lstTitles.NewIndex) = objRec!titleid
objRec.MoveNext
Loop



Here lsttitles is a listbox which has 2 list of values
1.Visible list with job_title column values
2.Invisible internal use list with titleid values

When the user clicks on the listbox then
lstTiles.Itemdata(lstTitles.selectedIndex) will return the titleid for the job_title clicked.

 
thanks but I tried using that line before and got an error
////
Msgbox(lstTiles.Itemdata(lstTitles.selectedIndex))
////

It highlights the .selectedIndex and says Method or data member not found. Any ideas? :)
 
never mind i got it now, thanks for the help ;)

it was

lstTitles.ItemData(lstTitles.ListIndex)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top