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. .

hmmm, trying moving .MoveNext to the outside of the loop.

same error

this is my error

mobjCmd.CommandText = strSQL

hope you can help me :(

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.