ник: Vik
Это уже нормально работает, только без запроса
Function InsetrParentsInTMP_2() As Long
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim strSQL As String
Dim CurID As Long
InsetrParentsInTMP_2 = 0
strSQL = "DELETE tblTMP.* FROM tblTMP;"
CurrentDb.Execute strSQL
Set rst1 = CurrentDb.OpenRecordset("qw_ForTMP")
Set rst2 = CurrentDb.OpenRecordset("qw_ForTMP")
rst1.MoveLast
rst1.MoveFirst
Do While Not rst1.EOF
CurID = rst1!DepID
StartFind:
rst2.FindFirst "DepID = " & CurID
If rst2.NoMatch = False Then
CurID = rst2!ParentID
strSQL = "INSERT INTO tblTMP ( DepIDTMP, ParentIDTMP ) VALUES ( " & rst1!DepID & ", " & CurID & ");"
CurrentDb.Execute strSQL
InsetrParentsInTMP_2 = InsetrParentsInTMP_2 + 1
GoTo StartFind
End If
rst1.MoveNext
Loop
rst1.Close
Set rst1 = Nothing
rst2.Close
Set rst2 = Nothing
End Function
|
Ухожу в отпуск, поэтому в ближайшие 2 недели вряд-ли буду часто на форуме.