I am using VB6, ADO and Access 2002.
I am trying to write the first three fields from a Db to a listview;
Fields names are:
First_Name, Middle_Name, Surname.
Now the name may, or may not have a middle name, and I think this is what is causing me the problem
I am getting something wrong with the writing to the Listview, but I'm not sure why.
I am getting the error
Invalid property value
when the second item is to be added.
My Code:
vb Code:
Set rs = New ADODB.Recordset Set cn = New ADODB.Connection cn.ConnectionString = strConnection & App.Path & "\Membership.mdb" cn.Open strSQL = "SELECT First_Name, Middle_Name, Surname FROM tbl_Membership " strSQL = strSQL & " WHERE First_Name <> '""'" rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText i = 1 Do While Not rs.EOF If rs!Middle_Name <> "" Then If i = 1 Then Set lvwItem = lvwMembers.ListItems.Add(, , rs!First_Name & " " & rs!Middle_Name & " " & rs!Surname) Else lvwItem.SubItems(i) = rs!First_Name & " " & rs!Middle_Name & " " & rs!Surname End If Else If i = 1 Then Set lvwItem = lvwMembers.ListItems.Add(, , rs!First_Name & " " & rs!Surname) Else lvwItem.SubItems(i) = rs!First_Name & " " & rs!Surname End If End If i = i + 1 rs.MoveNext Loop Set rs = Nothing cn.Close Set cn = Nothing





Reply With Quote