TREEVIEW1 COM DADOS ACCESS 5 NOS
Olá,
Consegue auxiliar , tenho este código que preciso fazer com variáveis para popular o TreeView1 com 5 nos com dados do access
A estrutura de colunas na Tabela é Regiao | Gerente | Consultor | Area | UF
Set cn = New ADODB.Connection
With cn
.ConnectionString = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & App.Path & [Ô]\DB_ARVORE.mdb[Ô]
.Open
End With
rs1.Open [Ô]Select * from TBL_ARVORE[Ô], cn, adOpenStatic, adLockOptimistic
With TreeView1
.Nodes.Add , , [Ô]A[Ô], [Ô] REGIAO A[Ô]
.Nodes.Add [Ô]A[Ô], tvwChild, [Ô]A1[Ô], [Ô]GERENTE[Ô]
.Nodes.Add [Ô]A1[Ô], tvwChild, [Ô]A1.1[Ô], [Ô]CONSULTOR[Ô]
.Nodes.Add [Ô]A1.1[Ô], tvwChild, [Ô]A1.1.1[Ô], [Ô]AREA[Ô]
.Nodes.Add [Ô]A1.1.1[Ô], tvwChild, [Ô]A1.1.1.1[Ô], [Ô]UF[Ô]
.Nodes.Add , , [Ô]B[Ô], [Ô]REGIAO B[Ô]
.Nodes.Add [Ô]B[Ô], tvwChild, [Ô]B1[Ô], [Ô]GERENTE[Ô]
.Nodes.Add [Ô]B1[Ô], tvwChild, [Ô]B1.1[Ô], [Ô]CONSULTOR[Ô]
.Nodes.Add [Ô]B1.1[Ô], tvwChild, [Ô]B1.1.1[Ô], [Ô]AREA[Ô]
.Nodes.Add [Ô]B1.1.1[Ô], tvwChild, [Ô]B1.1.1.1[Ô], [Ô]UF[Ô]
.Nodes.Add , , [Ô]C[Ô], [Ô]REGIAO C[Ô]
.Nodes.Add [Ô]C[Ô], tvwChild, [Ô]C1[Ô], [Ô]GERENTE DE MERCADO[Ô]
.Nodes.Add [Ô]C1[Ô], tvwChild, [Ô]C1.1[Ô], [Ô]CONSULTOR[Ô]
.Nodes.Add [Ô]C1.1[Ô], tvwChild, [Ô]C1.1.1[Ô], [Ô]AREA[Ô]
.Nodes.Add [Ô]C1.1.1[Ô], tvwChild, [Ô]C1.1.1.1[Ô], [Ô]UF[Ô]
.Nodes.Add , , [Ô]D[Ô], [Ô]REGIAO D[Ô]
.Nodes.Add [Ô]D[Ô], tvwChild, [Ô]D1[Ô], [Ô]GERENTE[Ô]
.Nodes.Add [Ô]D1[Ô], tvwChild, [Ô]D1.1[Ô], [Ô]CONSULTOR[Ô]
.Nodes.Add [Ô]D1.1[Ô], tvwChild, [Ô]D1.1.1[Ô], [Ô]AREA[Ô]
.Nodes.Add [Ô]D1.1.1[Ô], tvwChild, [Ô]D1.1.1.1[Ô], [Ô]UF[Ô]
.Nodes.Add , , [Ô]E[Ô], [Ô]REGIAO E[Ô]
.Nodes.Add [Ô]E[Ô], tvwChild, [Ô]E1[Ô], [Ô]GERENTE[Ô]
.Nodes.Add [Ô]E1[Ô], tvwChild, [Ô]E1.1[Ô], [Ô]CONSULTOR[Ô]
.Nodes.Add [Ô]E1.1[Ô], tvwChild, [Ô]E1.1.1[Ô], [Ô]AREA[Ô]
.Nodes.Add [Ô]E1.1.1[Ô], tvwChild, [Ô]E1.1.1.1[Ô], [Ô]UF[Ô]
End With
seria um loop que você precisa?
ex:
_______________________________________________-
rs1.Open [Ô]Select * from TBL_ARVORE[Ô], cn, adOpenStatic, adLockOptimistic
do while not rs1.eof
With TreeView1
.Nodes.Add , , [Ô]A[Ô], rs1([Ô]REGIAO[Ô])
.Nodes.Add [Ô]A[Ô], tvwChild, [Ô]A1[Ô], rs1([Ô]GERENTE[Ô])
.Nodes.Add [Ô]A1[Ô], tvwChild, [Ô]A1.1[Ô], rs1([Ô]CONSULTOR[Ô])
.Nodes.Add [Ô]A1.1[Ô], tvwChild, [Ô]A1.1.1[Ô], rs1([Ô]AREA[Ô])
.Nodes.Add [Ô]A1.1.1[Ô], tvwChild, [Ô]A1.1.1.1[Ô], rs1([Ô]UF[Ô])
End With
rs1.next
loop
ex:
_______________________________________________-
rs1.Open [Ô]Select * from TBL_ARVORE[Ô], cn, adOpenStatic, adLockOptimistic
do while not rs1.eof
With TreeView1
.Nodes.Add , , [Ô]A[Ô], rs1([Ô]REGIAO[Ô])
.Nodes.Add [Ô]A[Ô], tvwChild, [Ô]A1[Ô], rs1([Ô]GERENTE[Ô])
.Nodes.Add [Ô]A1[Ô], tvwChild, [Ô]A1.1[Ô], rs1([Ô]CONSULTOR[Ô])
.Nodes.Add [Ô]A1.1[Ô], tvwChild, [Ô]A1.1.1[Ô], rs1([Ô]AREA[Ô])
.Nodes.Add [Ô]A1.1.1[Ô], tvwChild, [Ô]A1.1.1.1[Ô], rs1([Ô]UF[Ô])
End With
rs1.next
loop
Isto é parte do loop no primeiro nó ,
agora preciso criar outros 5 Nos realizando um filtro na tabela e popular os nos filho .
rs2.Open [Ô]Select * from TBL_ARVORE WHERE REGIONAL=[Ô] & rs1([Ô]REGIAO[Ô]) & [Ô];[Ô], cn, adOpenStatic, adLockOptimistic
agora preciso criar outros 5 Nos realizando um filtro na tabela e popular os nos filho .
rs2.Open [Ô]Select * from TBL_ARVORE WHERE REGIONAL=[Ô] & rs1([Ô]REGIAO[Ô]) & [Ô];[Ô], cn, adOpenStatic, adLockOptimistic
O loop não esta funcionando .
[ô][ô] NO 1 REGIONAL
Do While Not rs1.EOF
.Nodes.Add , , [Ô]A[Ô] & I, rs1([Ô]REGIAO[Ô])
[ô][ô] NO 2 GERENTE
Do While Not rs2.EOF
.Nodes.Add [Ô]A[Ô] & I, tvwChild, [Ô]A1[Ô] & II, rs2([Ô]GERENTE[Ô])
[ô][ô] NO 3 CONSULTOR
Do While Not rs3.EOF
.Nodes.Add [Ô]A1[Ô] & II, tvwChild, [Ô]A1[Ô] & III, rs3([Ô]CONSULTOR[Ô])
[ô][ô] NO 4 AREA
Do While Not rs4.EOF
.Nodes.Add [Ô]A1[Ô] & III, tvwChild, [Ô]A1[Ô] & IV, rs4([Ô]AREA[Ô])
[ô][ô] NO 5 UF
Do While Not rs5.EOF
.Nodes.Add [Ô]A1[Ô] & IV, tvwChild, [Ô]A1[Ô] & V, rs5([Ô]UF[Ô])
V = V + 1
rs5.MoveNext
Loop
IV = IV + 1
rs4.MoveNext
Loop
III = III + 1
rs3.MoveNext
Loop
II = II + 1
rs2.MoveNext
Loop
I = I + 1
rs1.MoveNext
Loop
[ô][ô] NO 1 REGIONAL
Do While Not rs1.EOF
.Nodes.Add , , [Ô]A[Ô] & I, rs1([Ô]REGIAO[Ô])
[ô][ô] NO 2 GERENTE
Do While Not rs2.EOF
.Nodes.Add [Ô]A[Ô] & I, tvwChild, [Ô]A1[Ô] & II, rs2([Ô]GERENTE[Ô])
[ô][ô] NO 3 CONSULTOR
Do While Not rs3.EOF
.Nodes.Add [Ô]A1[Ô] & II, tvwChild, [Ô]A1[Ô] & III, rs3([Ô]CONSULTOR[Ô])
[ô][ô] NO 4 AREA
Do While Not rs4.EOF
.Nodes.Add [Ô]A1[Ô] & III, tvwChild, [Ô]A1[Ô] & IV, rs4([Ô]AREA[Ô])
[ô][ô] NO 5 UF
Do While Not rs5.EOF
.Nodes.Add [Ô]A1[Ô] & IV, tvwChild, [Ô]A1[Ô] & V, rs5([Ô]UF[Ô])
V = V + 1
rs5.MoveNext
Loop
IV = IV + 1
rs4.MoveNext
Loop
III = III + 1
rs3.MoveNext
Loop
II = II + 1
rs2.MoveNext
Loop
I = I + 1
rs1.MoveNext
Loop
Tópico encerrado , respostas não são mais permitidas