Click to See Complete Forum and Search --> : Help with Listview_Click


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

JC24
February 8th, 2000, 03:16 PM
How do you access the listview controls in VB6.0???

bzg0by
February 8th, 2000, 05:16 PM
I access the Listview controls by using the DAO in the project <tab> then by clicking on the references.
Sorry about being so basic. But I did not know if you were asking me how to access the listview or How was I accessing the listview.

Johnny101
February 8th, 2000, 05:48 PM
In project references, select Microsoft Windows Common Controls 6.0 SP3 - 1 (or 2).


John Pirkey
MCSD
www.ShallowWaterSystems.com

Johnny101
February 8th, 2000, 05:52 PM
maybe I missed it, but what are you asking? Do you need help with the query to return the correct values? Or referencing the correct subitem in the main listview control? or what?

a little clarification of your question would help,
thanks,
John

John Pirkey
MCSD
www.ShallowWaterSystems.com

bzg0by
February 9th, 2000, 12:35 PM
Hello Johnny; I apologize if I confused you... The problem I am having is wiht retrieving the values from table 3. to access in the listview control. I have written a query which works on the first 2 subitems. But due to the fact of how table 3 is configured I am having some problems. If you can help me in anyway I would really appreciate it. Thanks.