Why doesn't this work???

  • Thread starter Thread starter EAB1977
  • Start date Start date
E

EAB1977

I'm trying to get a name to pop up in a message box from my listbox
that I select, and I cannot for the life of me get the code below to
work!!!

Private Sub lstCloseoutAttendees_Click()
Dim ctl As Control, intCurrentRow As Integer

Set ctl = Me.lstCloseoutAttendees 'Listbox

For intCurrentRow = 0 To ctl.ListCount - 1
If ctl.Selected(intCurrentRow) Then
MsgBox ctlList.Column(2, intCurrentRow)
End If
Next intCurrentRow

End Sub
 
What are you expecting it to do? What does it do instead?

You hopefully realize that ctlList.Column(2, intCurrentRow) will give you
the result from the third column of the list box. Is the ColumnCount of the
list box set correctly? (Even if your RowSource has three or more fields in
it, unless the ColumnCount property reflects that fact, you can't use the
Column collection)
 
I am wanting the code to place this in a text box to be able to edit
the entry, but I wanted to make sure that it worked before I did that,
hence the message box.

As you state, I do have 3 columns (AuditNum, RecordNum, and Name in a
table called tblAuditCloseout) and the ColumnCount is set correctly.

If I can't use the column collection, then what do I use?
 
Back
Top