Bonjour
Voici mon problème
Sur un programme Vba Access j'utilise une fonction récursive que voici qui fonctionne très bien :
Function Nomenclature(Article As String, Rang As Long, Variante As String)
Set Db = CurrentDb
Sql = "SELECT * FROM Nomenclature" & " WHERE [Article]='" & Article & "' " & "AND [Variante]='" & Variante & "' ORDER BY [Composant]"
Set Rs = Db.OpenRecordset(Sql)
With Rs
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
MsgBox .Fields("Composant")
Call Nomenclature(.Fields("Composant"), Rang + 1, .Fields("Variante_Comp"))
.MoveNext
Loop
End If
.Close
End With
Rang = Rang - 1
End Function
j'ai traduit cette même fonction en delphi
que voici :
Procedure Nomenclature (Article : String ; Rang : Integer ; Variante : String) ;
begin
Sql :='Select * From Nomenclature Where [Article]=' +
QuotedStr(Article) + ' And [Variante]=' + QuotedStr(Variante) + ' ORDER BY [Composant]';
Rs:=CoRecordset.Create
RS.Open(Sql, Cnx, adOpenStatic, adLockOptimistic, adCmdText );
With RS do Begin
if (RecordCount > 0) then begin
MoveFirst;
While Not EOF DO Begin
Showmessage (Fields['Composant'].Value + '///'+ Article);
Nomenclature(Fields['Composant'].Value, Rang + 1,Fields['Variante_Comp'].Value) ;
MoveNext;
end ;
end ;
Close ;
end ;
Rang:=Rang - 1
end ;
mais le problème c'est que elle ne fonctionne pas de la même façon au niveau du recordset
redrad