Bonjour,

Je souhaite descendre une nomenclature d'ordre de fabrication. Un of débute sur une racine et présente une arborescence.

La table se nomme wo et a pour clé primaire id_wo et contient un champ qui est l'identifiant du père id_wo_parent.

J'ai codé:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 id_wo = id_of
                           fin_trt = False
 
                           Do Until fin_trt
 
                              ' On recherche les ofs qui ont pour père l'of racine et qui ont une situtation différente de "Terminée"
                              rsrecord_nom.Open " select  w.id_wo_parent, w.id_wo, w.num_wo, a.reference, a.designation from topmes.wo w inner join toperp.t_article a on w.id_article = a.id_article where nvl(w.id_status,0) <> 441 and w.qty_total > nvl(w.qty_outside,0) and w.id_wo_parent = " & id_wo & " order by w.id_wo ", conn, adOpenForwardOnly, adLockReadOnly
 
                              If Not rsrecord_nom.EOF Then
                                 rsrecord_nom.MoveFirst
 
                                 While Not rsrecord_nom.EOF
 
                                    lig = lig + 1
 
                                    With Worksheets("OF")
                                         .Range("A" & lig).Value = Rech_adr(rsRecords_aff.Fields("id_client_adresse").Value, rsRecords_aff.Fields("DESCRIPTION").Value)
                                         .Range("B" & lig).Value = rsRecords_aff.Fields("NUM_CMDE").Value
                                         .Range("C" & lig).Value = rsRecords_aff.Fields("NUM_LIGNE").Value
                                         .Range("D" & lig).Value = "OF : " & rsrecord_nom.Fields("num_wo").Value
                                         .Range("E" & lig).Value = " Qté à prod. : " & qte_a_prod_aff
                                         .Range("F" & lig).Value = " Qté livrable : " & qte_livrable_aff
                                         ' Identifiant de la ligne de commande client
                                         .Range("I" & lig).Value = rsRecords_aff.Fields("ID_CMDE_LIGNE").Value
                                         .Range("L" & lig).Value = rsrecord_nom.Fields("reference").Value
                                         .Range("M" & lig).Value = rsrecord_nom.Fields("designation").Value
                                         .Range("N" & lig).Value = rsrecord_nom.Fields("id_wo_parent").Value
                                         .Range("O" & lig).Value = rsrecord_nom.Fields("id_wo").Value
                                    End With
 
                                    id_wo = rsrecord_nom.Fields("id_wo").Value
                                    rsrecord_nom.MoveNext
                                 Wend
                              Else
                                 fin_trt = True
                              End If
 
                              rsrecord_nom.Close
                              Set rsrecord_nom = Nothing
 
                           Loop
Cela ne me permet pas de descendre l'intégralité de l'arborescence. 2 niveaux sont descendus uniquement.

Je ne vois pas le problème dans ma boucle.