Ok i have this form used for registering user for my program (User and Admin type)

When i run it, i get an error that says "Invalid Property Value"

This is my code for my GetUsers function called on my Form_Load event

Public Sub GetUsers()

'    On Error GoTo eh
Call con
        
    Set rs = New ADODB.Recordset

    With rs
        If .State = adStateOpen Then .Close
        
        .Open "Select * From Users Order By UserName;", Dbconn, adOpenKeyset, adLockOptimistic
        
        If rs.EOF = True Then
            lvwUser.ListItems.Clear
            Exit Sub
            
        End If
        
        lvwUser.ListItems.Clear
        Do While .EOF = False
            lvwUser.ListItems.Add , , .Fields("ID")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(2) = .Fields("UserName")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("Password")
           'lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("UserType")
            .MoveNext
        Loop
    End With


    Exit Sub
    
eh:
    MsgBox err.Description, vbCritical


End Sub

This is where i am getting the error.

Do While .EOF = False
            lvwUser.ListItems.Add , , .Fields("ID")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(2) = .Fields("UserName")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("Password")
           'lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("UserType")
            .MoveNext
        Loop

I fix it using this code:

ListView1.ListItems.Add , , rs!ID
 ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , rs!UserName
 ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , rs!Password
    rs.MoveNext

It does fix it but when i reRun my program, there are no records on my listview control

even if i have three records on my database.

I am using a Listview control and view is Report.

Code of my listview:

Private Sub lvwUser_ItemClick(ByVal Item As MSComctlLib.ListItem)

On Error GoTo err
    Set rs = New ADODB.Recordset

    With rs
    
        If .State = adStateOpen Then .Close
      
        
              .Open "SELECT * FROM Users where ID = '" & lvwUser.SelectedItem.Text, Dbconn, adOpenKeyset, adLockOptimistic
        
            txtName.Text = .Fields("UserName")
            txtPass.Text = .Fields("PassWord")
            txtConfirm.Text = .Fields("PassWord")
            cboPriv.Text = "Admin"
            
    End With
    Exit Sub
    
err:
    MsgBox err.Description, vbCritical
End Sub

What am i missing.

Check your listview property like, if Listview propert view is Report style (detailed style) then make sure you have column headers.

ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add "ID"
ListView1.ColumnHeaders.Add "Username"
ListView1.ColumnHeaders.Add "Password"

Above code is just sample, so please try it out. Thanks

Have you tried to refresh your listview?

ListView1.Refresh

Do this when the button is clicked...

yes sir, didn't work.

But fix already.

My mistake was using MS Windows Common Controls 5.0 and 6.0 at the same time.

Fix by removing 5.0. Haha, I'm such a noob.

Replies are appreciated, THanks.

Comments
Well done...

Hehehe.;)

We all went through this. Once you're involved in an application, you tend to loose track of all the components you are referencing. Thats why its always good to use good naming conventions etc.:)

This question has already been answered. Start a new discussion instead.