Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 get value of n'th colum of selected listbox item.

Author  Topic 

pyrrhus_finch
Yak Posting Veteran

51 Posts

Posted - 2005-02-19 : 15:17:56
I have a form with three listboxes, wherein the user can select only one value to go to the appropriate form.

listbox1 - lists records marked 'new'
listbox2 - lists records marked 'active'
listbox3 - lists records marked 'resolved'


each listbox has 4 columns (though column 1 width is 0")
ID, CustID, Date, Record_Type

how do i fetch the value of the selected record?

I made a button to pop up a message to see what values were being passed.

Private Sub cmdTest_Click()
Dim varTest As String
'varTest = Me.listbox2
varTest = listbox2.Value
MsgBox ("Selected:" & varTest), vbOKOnly + vbExclamation, "Kilroy Was here"
End Sub

It gives me only the date of the selected record (the first visible column).

So:
If I wanted to get the 'ID' (column1) and 'Record_Type' (column4) values of the selected coulmn and pass them to my variable, how would I do that?

AND: is there a way to get the value for the active selection without specifying which list box it appears in - since im only allowing one selected value on the page.

Thanks!


Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2005-02-20 : 00:33:09
Private Sub CmdTest_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox Me.ActiveControl.Column(0) & " " & Me.ActiveControl.Column(3)
End Sub

But oops... clicking CmdTest turns it to be Current Active Control.
Go to Top of Page

pyrrhus_finch
Yak Posting Veteran

51 Posts

Posted - 2005-02-21 : 13:55:12
Yes.. so i erase the button and use a double click event! =;
Go to Top of Page
   

- Advertisement -