I’m not getting any errors returning database information. That is working
just fine. My problem is with the ListView Control.
Here is the code section where the error is occurring:
strSQL = "SELECT " & strTbl & ".* FROM " & strTbl & ";"
iRow = 1
rsData.Open strSQL, cnnDB, adOpenKeyset, adLockReadOnly
With rsData
If .RecordCount <> 0 Then
Do While Not .EOF
For I = 1 To lvTblCols.ColumnHeaders.Count
'Get field name on listview column
strFld = lvTblCols.ColumnHeaders(I).Text
'Get the listview key
strCol = CStr(lvTblCols.ColumnHeaders(I).Key)
'Write data on the proper row under the proper column
Set itmX = lvTblCols.ListItems.Add(iRow, strCol,
rsData(strFld).Value)
‘I get an Invalid Property error on the line below.
itmX.SubItems(lvTblCols.ColumnHeaders(strCol).SubItemIndex) =
rsData(strFld).Value
Next I
iRow = iRow + 1
.MoveNext
Loop
End If
End With
It does not recognize the subitem value for some reason.
Thank you,

Signature
Mark
> I'm not an expert in SQL, but this might wake them up ;)
> First, you're using only one Table in strSQL = "SELECT " & strTbl & ".* FROM
[quoted text clipped - 56 lines]
> > Resume List_Tbl_Data_Exit
> > End Sub
Henning - 26 May 2006 12:41 GMT
If you throw in the debug.print below to see what values there are, might
give a clue.
/Henning
> I'm not getting any errors returning database information. That is working
> just fine. My problem is with the ListView Control.
[quoted text clipped - 15 lines]
> rsData(strFld).Value)
> 'I get an Invalid Property error on the line below.
Debug.Print lvTblCols.ColumnHeaders(strCol).SubItemIndex
Debug.Print rsData(strFld).Value
> itmX.SubItems(lvTblCols.ColumnHeaders(strCol).SubItemIndex) =
> rsData(strFld).Value
[quoted text clipped - 69 lines]
> > > Resume List_Tbl_Data_Exit
> > > End Sub
bitshifter - 26 May 2006 17:24 GMT
Sorry to be a Joe-come-lately but I had problems before using the
.RecordCount without doing a little dance like
.MoveLast
followed by .MoveFirst
It never hurts...
>I’m not getting any errors returning database information. That is working
>just fine. My problem is with the ListView Control.
[quoted text clipped - 89 lines]
>> > Resume List_Tbl_Data_Exit
>> > End Sub
Henning - 26 May 2006 20:04 GMT
.RecordCount in this case, is the number of records that match the
SQL-query, here that is all records.
While I'm here, I see both ListItem and SubItem would receive the same
value.
/Henning
> Sorry to be a Joe-come-lately but I had problems before using the
> .RecordCount without doing a little dance like
[quoted text clipped - 4 lines]
>
> >Iâ?Tm not getting any errors returning database information. That is
working
> >just fine. My problem is with the ListView Control.
> >
[quoted text clipped - 88 lines]
> >> > Resume List_Tbl_Data_Exit
> >> > End Sub
Richard Mueller - 31 May 2006 19:26 GMT
Hi,
When you retrieve RecordCount, it moves the cursor to the end of the
recordset. You need to use MoveFirst before enumerating the recordset or EOF
will be True and no records processed.

Signature
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
> Sorry to be a Joe-come-lately but I had problems before using the
> .RecordCount without doing a little dance like
[quoted text clipped - 102 lines]
>>> > Resume List_Tbl_Data_Exit
>>> > End Sub