I have a list box with 3 columns.
I'm trying to get the third column of the selected item.
I CLICK and select an item from the list box, then click "Read Data" button with following code.
It works perfect and I have what I was looking for.
Now I use the following code to select an item.
If I click the "Read Data" button, I receive an error :
Run time error "94" Invalid use of Null.
Why clicking and selecting an item from a list box is different with using code and selecting an item?
A demo file is attached.
1- Click and select an item from the list box, then click "Read Data" button. You receive a msgbox with third column value.
2- Click "Select an Item" button to select a random item , then click "Read Data". You receive the error.
Thanks for any advice.
I'm trying to get the third column of the selected item.
I CLICK and select an item from the list box, then click "Read Data" button with following code.
Code:
Private Sub btnReadData_Click()
With lstBox
If .ItemsSelected.Count = 1 Then
MsgBox .Column(2)
End If
End With
End Sub
It works perfect and I have what I was looking for.
Now I use the following code to select an item.
Code:
Private Sub btnSelect_Click()
With lstBox
.Selected(3) = True
End With
End Sub
If I click the "Read Data" button, I receive an error :
Run time error "94" Invalid use of Null.
Why clicking and selecting an item from a list box is different with using code and selecting an item?
A demo file is attached.
1- Click and select an item from the list box, then click "Read Data" button. You receive a msgbox with third column value.
2- Click "Select an Item" button to select a random item , then click "Read Data". You receive the error.
Thanks for any advice.
Attachments
Last edited: