Scusa grazie mille ci sono arrivato oggi alle 15:00
guarda un po' che bello:
codice:
Private Sub cForm_EsitoRicerca(xRs As ADODB.Recordset)
On Error Resume Next
Dim nInd As Long
Dim N As Node
Dim M As Node
Dim O As Node
Dim Q As Node
'**************PRIMO NODO**********************************
Do While Not xRs.EOF
'relative = vuoto se principale //
Set N = trvAlbero.Nodes.Add()
N.ForeColor = vbRed
N.Text = xRs!Gruppo & " - " & xRs!Descrizione
N.Tag = xRs!Gruppo
N.Key = "NN" & xRs!ID
' N.Tag
nInd = N.Index
nsub = N.Child
'*****************SECONDO NODO******************************
Dim cRs As New ADODB.Recordset
cRs.Open "SELECT * FROM CLASSE WHERE Annullamento = False AND ID_GRUPPO = " & xRs!ID, Cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While Not cRs.EOF
Set M = trvAlbero.Nodes.Add(nInd, tvwChild)
M.Text = cRs!Classe & " - " & cRs!Descrizione
M.Tag = cRs!Classe
M.Key = "MM" & cRs!ID
mInd = M.Index
'****************TERZO NODO*********************************
Dim sRs As New ADODB.Recordset
sRs.Open "SELECT * FROM CONTO WHERE Annullamento = False AND ID_CLASSE = " & cRs!ID, Cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While Not sRs.EOF
'qui cosa scrivo
Set O = trvAlbero.Nodes.Add(mInd, tvwChild)
O.Text = sRs!Conto & " - " & sRs!Descrizione
O.Tag = sRs!Conto
O.Key = "OO" & sRs!ID
oInd = O.Index
'****************QUARTO NODO********************************
Dim oRs As New ADODB.Recordset
oRs.Open "SELECT * FROM CENTRO WHERE Annullamento = False AND ID_CONTO = " & sRs!ID, Cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While Not oRs.EOF
Set Q = trvAlbero.Nodes.Add(oInd, tvwChild)
Q.Text = oRs!CENTRO & " - " & oRs!Descrizione
Q.Tag = oRs!CENTRO
Q.Key = "QQ" & oRs!ID
qInd = Q.Index
oRs.MoveNext
Loop
oRs.Close
Set oRs = Nothing
sRs.MoveNext
Loop
sRs.Close
Set sRs = Nothing
cRs.MoveNext
Loop
cRs.Close
Set cRs = Nothing
xRs.MoveNext
Loop
'cRs.Close
'Set cRs = Nothing
'sRs.Close
'Set sRs = Nothing
trvAlbero.BorderStyle = ccFixedSingle
End Sub
Funzia benone
Grazie ancora!!