Error 91: object variable or with block variable not set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sahitya sidda
    New Member
    • Aug 2007
    • 1

    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

    [CODE=vb]Private Sub ListPersons_Dbl Click()

    Dim row As Integer
    Dim item As ListItem
    Dim personid As Double
    Dim bsuccess As Boolean
    Dim msName As String


    'Listpersons is the name of listview
    row = ListPersons.Sel ectedItem.index
    personid = ListPersons.Lis tItems(row)

    End Sub[/CODE]

    Or can anyone suggest any other method for retrieving the index of selecteditem in listview?
    Last edited by Killer42; Aug 27 '07, 06:57 AM. Reason: Added CODE=vb tag
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by sahitya sidda
    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.
    [CODE=vb]Dim item As ListItem[/CODE]
    to
    [CODE=vb]Dim item As New ListItem[/CODE]


    Where are you using this item in this method?


    [CODE=vb]personid = ListPersons.Lis tItems(row).Tex t[/CODE]
    or
    [CODE=vb]personid = ListPersons.Lis tItems(row).Sub item(<Column_In dex>)[/CODE]
    Last edited by Killer42; Aug 27 '07, 07:02 AM. Reason: Shortened quote block

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Could this simply indicate that no item is currently selected? (I'm not very familiar with the ListView control.)

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Originally posted by Killer42
        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.

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

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

          [code=vb]
          Dim TItem As ListItem
          If lvw.SelectedIte m.text <> "" Then
          Set TItem = lvw.SelectedIte m
          End If
          [/code]

          Regards
          Veena

          Comment

          Working...