VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Acess Data Show in Treeview & Listview

by Ashish Parmar (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 19th April 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Acess Data Show in Treeview & Listview

API Declarations


' 1 Add the 1 command button
' 2 Add the 2 CommonDialogbox and change the name Cd
' 3 Add the 3 Listview Tv
' 4 Add the 4 Treeview Tv1
' If you have any proble for run this application pl. contect me
' [email protected],[email protected], and u have any idea write me mail

Dim i As Integer
Dim tmp As Node
Dim db As Database
Dim rs As Recordset


Rate Acess Data Show in Treeview & Listview



    Dim Node As Node
    Dim etape1 As Node
    Dim etape2 As Node
    i = 1
    cd.ShowOpen
    cd.Filter = "Access File|*.mdb"
    Set db = OpenDatabase(cd.FileName)
    Dim tbl As TableDef
    tv1.Nodes.Clear
    Set Node = tv1.Nodes.Add(, , , "Table Name", 0, 0)
    Node.Expanded = True
    Dim FLD As Field
       For Each tbl In db.TableDefs
           If Left(tbl.Name, 4) <> "MSys" Then
           Set etape1 = tv1.Nodes.Add(Node, tvwChild, , tbl.Name, Num, Num)
               For Each FLD In db.TableDefs(tbl.Name).Fields
                  Set etape2 = tv1.Nodes.Add(etape1, tvwChild, , FLD.Name, 0, 0)
               Next
           End If
        Next
End Sub

Private Sub tv1_NodeClick(ByVal Node As MSComctlLib.Node)
    Dim rsl As Recordset
    Dim it As ListItem
    Set rsl = db.OpenRecordset("select * From " & Node.Text)
    tv.ListItems.Clear
    tv.ColumnHeaders.Clear
    For Hname = 0 To rsl.Fields.Count - 1
        tv.ColumnHeaders.Add , , rsl.Fields(Hname).Name
    Next
    Do While Not rsl.EOF
       Set it = tv.ListItems.Add(, , rsl.Fields(0).Value)
           For Fval = 1 To rsl.Fields.Count - 1
              it.SubItems(Fval) = IIf(IsNull(rsl.Fields(Fval)), "", rsl.Fields(Fval))
           Next
       rsl.MoveNext
    Loop
End Sub


Download this snippet    Add to My Saved Code

Acess Data Show in Treeview & Listview Comments

No comments have been posted about Acess Data Show in Treeview & Listview. Why not be the first to post a comment about Acess Data Show in Treeview & Listview.

Post your comment

Subject:
Message:
0/1000 characters