Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listView problem

Status
Not open for further replies.

ChewDoggie

Programmer
Mar 14, 2005
604
0
0
US
g'morning all!

I have what seems to be the easiest problem to solve, but cannot for the sake of me figure this out. Maybe I need to change coffee brands or something.

Anyway, I have a listview with six columns:

ClassID, Class Description, Bike Abbreviation, Competition Number, Engine Size and BikeID

The ClassID and BikeID fields are not visible to the user. My problem is that I cannot seem to grab the Class Description EVEN THOUGH I can see the darn description on the screen. Here's a code snippet:

ClassDesc = lstHist.ListItems(1).SubItems(0)
BikeAbbr = lstHist.ListItems(1).SubItems(1)
CompNum = lstHist.ListItems(1).SubItems(2)
EngineSize = lstHist.ListItems(1).SubItems(3)
ClassID = lstHist.ListItems(1).SubItems(4)
BikeID = crs!bikeid = lstHist.ListItems(1).SubItems(5)

The Error states "Invalid Property Value" on the ClassDesc line. It seem to me that if I can SEE THE DESCRIPTION, I should be able to grab it programmatically.

Here's how I load the ListView with Data:

sql = "select * from vreghistory where racerid=" & txtRacerid.Text
Set rsHist = New ADODB.Recordset
rsHist.Open sql, cn, adOpenKeyset, adLockReadOnly
lstHist.ListItems.Clear
If rsHist.RecordCount = 0 Then
cmdAddAllClasses.Enabled = False
cmdAddClass.Enabled = False
Else
cmdAddAllClasses.Enabled = True
cmdAddClass.Enabled = True
Do While Not rsHist.EOF
' add the main ListItem object
Set li = lstHist.ListItems.Add(, , rsHist!Description & "")
' add all subsequent ListSubItem objects
li.ListSubItems.Add , , rsHist!brandabr & ""
li.ListSubItems.Add , , rsHist!comp & ""
li.ListSubItems.Add , , rsHist!bikesize & ""
li.ListSubItems.Add , , rsHist!classid
li.ListSubItems.Add , , rsHist!brandid
rsHist.MoveNext
Loop
End If
rsHist.Close

Thanks!







Many Thanks!

AMACycle

American Motorcyclist Association
 
Think the sub items start from 1.

Does :
Code:
ClassDesc = lstHist.ListItems(1).Text
return what you need?
 
Also, an FYI- the SubItems collection begins with an index of 1 (not 0).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top