1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Public Sub remplissageTreeView(oT As Object, odb As DAO.Database, Optional intEmploye As Integer = 0)
Dim strSQL As String
Dim oRst As DAO.Recordset
Dim strLibelle As String
strSQL = "SELECT NumEmploye,NomEmploye,PrenomEmploye,RoleEmploye FROM tblemploye WHERE Responsableemploye=" & intEmploye
Set oRst = odb.OpenRecordset(strSQL)
With oRst
While Not .EOF
'Récupère le nom, le prénom et le role
strLibelle = .Fields(1).Value & " " & .Fields(2).Value & " (" & .Fields(3).Value & ")"
'Test le cas de la racine
If intEmploye = 0 Then
oT.Nodes.Add "Emp" & .Fields(0).Value, strLibelle
Else
oT.Nodes.Add "Emp" & intEmploye, tvwChild, "Emp" & .Fields(0).Value, strLibelle
End If
'Lance le même traitement avec ce responsable
remplissageTreeView oT, odb, .Fields(0).Value
'Passe à l'enregistrement suivant
.MoveNext
Wend
End With
'Ferme le recordset
oRst.Close
Set oRst = Nothing
End Sub |
Partager