0

i cant load my data in listview


this is my code

Private Sub LoadCustomerListView()
    Dim strSQL As String
    Dim objCurrLI As ListItem
    
    strSQL = "Select Lastname" _
           & "     , Firstname" _
           & "     , Address" _
           & "     , Idnumber" _
           & "     , Gender" _
           & " From Student " _
           & " Order by Lastname"
    
  
    [B]mobjCmd.CommandText = strSQL[/B]
    Set mobjRst = mobjCmd.Execute
    
    ListView1.ListItems.Clear
    
    With mobjRst
         Do Until .EOF
         Set objCurrLI = ListView1.ListItems.Add(, , !Lastname & "", , "Custs")
         objCurrLI.SubItems(Firstname) = !Firstname & ""
         objCurrLI.SubItems(idnumber) = !idnumber & ""
         objCurrLI.SubItems(Address) = !Address & ""
         objCurrLI.SubItems(Gender) = !Gender & ""
         .MoveNext
         Loop
    End With
    ListView1.ListItems.Clear
    
    Set objCurrLI = Nothing
    Set mobjRst = Nothing
    
End Sub

the error is "Object Variable or With Block variable not set" that is the error. .

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Comatose
0

same error

this is my error

mobjCmd.CommandText = strSQL

hope you can help me :(

0

Oh, yeah. mobjCmd isn't defined. From what I can see, you are using mobjCmd... but nowhere in your code did you dim mobjcmd, and also, I don't see where you set mobjcmd = something.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.