listbox question

Matrix_zero

Registered User.
Local time
Today, 15:59
Joined
Jan 26, 2005
Messages
64
Is there a way i can say:


onclick
go to the row i have clicked on(whcih may be the top row, or any other row) and put the 3rd colum in that row into a variable
 
Code:
Private Sub lstMyList_AfterUpdate()
  Me.Recordset.FindFirst "[<fieldName>] = '" & Me.lstMyList.Column(0) & "'"
  myVariable = Me.lstMyList.Column(2)  'Third Coloum
End Sub

I think that might be what you are looking for, but im not to sure what is ment by
go to the row i have clicked on
 
"go to the row i have clicked on "

i mean, in a listbox there may be 4 or 5 rows, if i click on row 4, i want to get the data out of colum 4 or 5 of that row, not the top row.

Is that possible?
 
Last edited:
Yes that is possible.

Private Sub lstMyList_AfterUpdate()
debug.print Me.lstMyList.column(4) 'Selected row, column 5
debug.print Me.lstMyList.ListIndex 'The index of the selected row starting at 0
 
Well the probelem is that i don't know what row exactally the user may be clicking on. I am using it as a search. The row becomes highlited when clicked once. Is there a way to say "The highlighted row"
 
Last edited:
found an answer to my own question, jus thought i should post it in case anyone else wanted to know, i had to use the listindex function of the listbox to find out which row was hightlighted, then i can use the code

Private Sub lstMyList_AfterUpdate()
Me.Recordset.FindFirst "[<fieldName>] = '" & Me.lstMyList.Column(0) & "'"
myVariable = Me.lstMyList.Column(2) 'Third Coloum
End Sub

well... i guess i am on the right track at least
 
Me.datalookup.Column(2, Me.datalookup.ListIndex + 1)
this selects the 3rd colum in the row i select
 

Users who are viewing this thread

Back
Top Bottom