Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
rs.Open "select * from tb ", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.MoveFirst
Do Until rs.EOF
rs1.Open "select * from tb where [end]='" & rs("end") & "' ", CurrentProject.Connection
Do While Not IsNull(DLookup("parent", "tb", "COMPONENT='" & rs("parent") & "'")) And Not rs1.EOF
rs1.MoveNext