bzg0by
February 8th, 2000, 12:45 AM
I need some help please, I am having a problem with a Listview_Click...
I am using 2 listview ctrls in VB 6.0. Also I am using Access 97 as my database. I have 3 tables in my database. These are sample databases.
TABLE 1 TABLE 2
Ver Seq Sports Ver Sports Team
1 0 ftball 1 ftball cowboys
1 1 ftball 1 ftball titans
1 0 bskball 1 bskball rockets
1 1 bskball 1 bskball mavs
1 2 bskball 1 bskball lakers
Now here is where the problem comes in
Since the tables are so different I am having a problem with Table 3(The code is below)
TABLE 3
KeyTeam Player1 Player2 Player3
cowboys emmitt troy
titans eddie steve kearse
rockets hakeem steve
mavs finley rodman
lakers shaq rice green
This is the code on the click event from listview1
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim oRS As Recordset
Dim oRSV As Recordset
Dim oListItem(2) As ListItem
Dim lCntr As Long
Dim x As Long
Set oRS = oDB.OpenRecordset(" SELECT DISTINCT Table1.Seq, Table2.Team " & _
" FROM Table3 INNER JOIN (SegmentDef INNER JOIN Fields ON (Table1.Field = Table2.Field) AND (Table1.Ver = Table2.Ver)) ON Table3.Keyteam = Table1.Segment " & _
" Where (((Table3.Keyteam) = """ & Item.ListSubItems(1).Text & """) And ((Table1.Ver) = ""1"")) " & _
" ORDER BY Table1.Seq ", dbOpenForwardOnly)
Set oRSV = oDB.OpenRecordset("select * from Table3 " & _
"WHERE (Table3.Keyteam) = " & "'" & Item.ListSubItems(1).Text & "'", dbOpenForwardOnly)
ListView2.Visible = False
ListView2.ListItems.Clear
lCntr = oRSV.Fields.Count - 1
For x = 1 To lCntr
Set oListItem(2) = ListView2.ListItems.Add(, , oRS("Sports"))
oListItem(2).ListSubItems.Add , , oRS("Team")
If Not IsNull(oRSV.Fields(x)) Then
oListItem(2).ListSubItems.Add , , oRSV.Fields(x)
End If
oRSV.MoveNext
Next x
Set oRS = Nothing
Set oRSV = Nothing
ListView2.Visible = True
End Sub
I am using 2 listview ctrls in VB 6.0. Also I am using Access 97 as my database. I have 3 tables in my database. These are sample databases.
TABLE 1 TABLE 2
Ver Seq Sports Ver Sports Team
1 0 ftball 1 ftball cowboys
1 1 ftball 1 ftball titans
1 0 bskball 1 bskball rockets
1 1 bskball 1 bskball mavs
1 2 bskball 1 bskball lakers
Now here is where the problem comes in
Since the tables are so different I am having a problem with Table 3(The code is below)
TABLE 3
KeyTeam Player1 Player2 Player3
cowboys emmitt troy
titans eddie steve kearse
rockets hakeem steve
mavs finley rodman
lakers shaq rice green
This is the code on the click event from listview1
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim oRS As Recordset
Dim oRSV As Recordset
Dim oListItem(2) As ListItem
Dim lCntr As Long
Dim x As Long
Set oRS = oDB.OpenRecordset(" SELECT DISTINCT Table1.Seq, Table2.Team " & _
" FROM Table3 INNER JOIN (SegmentDef INNER JOIN Fields ON (Table1.Field = Table2.Field) AND (Table1.Ver = Table2.Ver)) ON Table3.Keyteam = Table1.Segment " & _
" Where (((Table3.Keyteam) = """ & Item.ListSubItems(1).Text & """) And ((Table1.Ver) = ""1"")) " & _
" ORDER BY Table1.Seq ", dbOpenForwardOnly)
Set oRSV = oDB.OpenRecordset("select * from Table3 " & _
"WHERE (Table3.Keyteam) = " & "'" & Item.ListSubItems(1).Text & "'", dbOpenForwardOnly)
ListView2.Visible = False
ListView2.ListItems.Clear
lCntr = oRSV.Fields.Count - 1
For x = 1 To lCntr
Set oListItem(2) = ListView2.ListItems.Add(, , oRS("Sports"))
oListItem(2).ListSubItems.Add , , oRS("Team")
If Not IsNull(oRSV.Fields(x)) Then
oListItem(2).ListSubItems.Add , , oRSV.Fields(x)
End If
oRSV.MoveNext
Next x
Set oRS = Nothing
Set oRSV = Nothing
ListView2.Visible = True
End Sub