469,133 Members | 1,167 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,133 developers. It's quick & easy.

Error 91: object variable or with block variable not set

"Error 91: object variable or with block variable not set"

I am getting the above error while retrieving the index of selected row in listview.

Please help me out

Expand|Select|Wrap|Line Numbers
  1. Private Sub ListPersons_DblClick()
  2.  
  3. Dim row As Integer
  4. Dim item As ListItem
  5. Dim personid As Double
  6. Dim bsuccess As Boolean
  7. Dim msName As String
  8.  
  9.  
  10. 'Listpersons is the name of listview
  11. row = ListPersons.SelectedItem.index
  12. personid = ListPersons.ListItems(row)
  13.  
  14. End Sub
Or can anyone suggest any other method for retrieving the index of selecteditem in listview?
Aug 27 '07 #1
4 3431
hariharanmca
1,977 1GB
Error 91 ...
Search for your query first and post new. Because here many post in same
topic. Anyhow change

you have to create 'New' instance for an object.
Expand|Select|Wrap|Line Numbers
  1. Dim item As ListItem
to
Expand|Select|Wrap|Line Numbers
  1. Dim item As New ListItem

Where are you using this item in this method?


Expand|Select|Wrap|Line Numbers
  1. personid = ListPersons.ListItems(row).Text
or
Expand|Select|Wrap|Line Numbers
  1. personid = ListPersons.ListItems(row).Subitem(<Column_Index>)
Aug 27 '07 #2
Killer42
8,435 Expert 8TB
Could this simply indicate that no item is currently selected? (I'm not very familiar with the ListView control.)
Aug 27 '07 #3
hariharanmca
1,977 1GB
Could this simply indicate that no item is currently selected? (I'm not very familiar with the ListView control.)
Yes, Thanks for the pick up.

if the Listview don't have any item and if you select the list view, it'll show this error.
Aug 27 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

to check if any Item in List is selected or not :

Expand|Select|Wrap|Line Numbers
  1. Dim TItem As ListItem
  2. If lvw.SelectedItem.text <> "" Then
  3.    Set TItem = lvw.SelectedItem
  4. End If
  5.  
Regards
Veena
Aug 27 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ike | last post: by
6 posts views Thread by Peter Frost | last post: by
4 posts views Thread by majo | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.