CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2000
    Posts
    6

    Help with Listview_Click

    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






  2. #2
    Join Date
    Feb 2000
    Posts
    2

    Re: Help with Listview_Click

    How do you access the listview controls in VB6.0???


  3. #3
    Join Date
    Jan 2000
    Posts
    6

    Re: Help with Listview_Click

    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.


  4. #4
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Help with Listview_Click

    In project references, select Microsoft Windows Common Controls 6.0 SP3 - 1 (or 2).


    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  5. #5
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Help with Listview_Click

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  6. #6
    Join Date
    Jan 2000
    Posts
    6

    Re: Help with Listview_Click

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured