VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7920
ClientLeft = 60
ClientTop = 450
ClientWidth = 8625
LinkTopic = "Form1"
ScaleHeight = 7920
ScaleWidth = 8625
StartUpPosition = 3 'Windows Default
Begin MSComctlLib.TreeView TreeView1
Height = 5655
Left = 1800
TabIndex = 0
Top = 720
Width = 4815
_ExtentX = 8493
_ExtentY = 9975
_Version = 393217
LineStyle = 1
Style = 7
Appearance = 1
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim CON As New ADODB.Connection
Dim RsCountry As New ADODB.Recordset
Dim RsState As New ADODB.Recordset
Dim RsDist As New ADODB.Recordset
Private Sub Form_Load()
Dim PATH
Dim X As Integer
Dim Y As Integer
Dim Z As Integer
Dim Country As String
Dim State As String
Dim Dist As String
PATH = App.PATH & "\COUNTRY.MDB"
CON.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & PATH & ";Persist Security Info=False"
CON.Open
Call RsCountry.Open("COUNTRY", CON, 1, 2, -1)
Call RsState.Open("STATE", CON, 1, 2, -1)
Call RsDist.Open("DISTRICT", CON, 1, 2, -1)
TreeView1.Nodes.Add , , "root", "COUNTRY'S NAME"
'Country
For X = 1 To RsCountry.RecordCount
Country = RsCountry(0)
TreeView1.Nodes.Add "root", tvwChild, Country, RsCountry(1)
'State
RsState.Filter = 0
RsState.Filter = "c_no='" + RsCountry(0) + "'"
For Y = 1 To RsState.RecordCount
TreeView1.Nodes.Add Country, tvwChild, RsState(1), RsState(2)
'Dist
State = RsState(1)
RsDist.Filter = 0
RsDist.Filter = "s_no='" + RsState(1) + "'"
For Z = 1 To RsDist.RecordCount
TreeView1.Nodes.Add State, tvwChild, RsDist(1), RsDist(2)
RsDist.MoveNext
Next Z
RsState.MoveNext
Next Y
RsCountry.MoveNext
Next X
End Sub