Function Proverka() Dim str As String, rs As DAO.Recordset, strTmp As String, rsTmp As DAO.Recordset Dim rsDelete As DAO.Recordset, rsDeleteTmp As DAO.Recordset Dim Code As Long, CodeTmp As Long Dim l As Currency, LTmp As Currency Dim d As Currency, DTmp As Currency Dim Kolvo As Long, KolvoTmp As Long Dim Volume As Currency, VolumeTmp As Currency Dim Volume_All As Currency, Volume_AllTmp As Currency str = "SELECT Specifick.SpecID, Specifick.DocID, Specifick.CodeID, Specifick.Long, Specifick.Diametr, Specifick.Volume, Specifick.[Kol-vo], Specifick.Volume_All " & _ "FROM Specifick " & _ "WHERE (((Specifick.DocID) = " & GDocId & ")) " & _ "ORDER BY Specifick.CodeID, Specifick.Long, Specifick.Diametr;" strTmp = "SELECT tmp_Specifick.SpecID, tmp_Specifick.DocID, tmp_Specifick.CodeID, tmp_Specifick.Long, tmp_Specifick.Diametr, tmp_Specifick.Volume, tmp_Specifick.[Kol-vo], tmp_Specifick.Volume_All " & _ "FROM tmp_Specifick " & _ "WHERE (((tmp_Specifick.DocID) = " & GDocId & ")) " & _ "ORDER BY tmp_Specifick.CodeID, tmp_Specifick.Long, tmp_Specifick.Diametr;" Set rs = CurrentDb().OpenRecordset(str) Set rsTmp = CurrentDb().OpenRecordset(strTmp) With rs If Not .EOF Then rsTmp.FindFirst "(((tmp_Specifick.CodeID)=" & !CodeID & ") AND ((tmp_Specifick.Long)=" & !Long & ") AND ((tmp_Specifick.Diametr)=" & !Diametr & "))" Do Until .EOF If rsTmp.NoMatch Then .Delete End If .MoveNext If Not .EOF Then rsTmp.FindNext "(((tmp_Specifick.CodeID)=" & !CodeID & ") AND ((tmp_Specifick.Long)=" & !Long & ") AND ((tmp_Specifick.Diametr)=" & !Diametr & "))" End If Loop End If .Close End With rsTmp.Close Set rs = CurrentDb().OpenRecordset(str) Set rsTmp = CurrentDb().OpenRecordset(strTmp) With rsTmp If Not rs.EOF And Not .EOF Then rs.MoveFirst .MoveFirst End If If Not .EOF Then rs.FindFirst "(((Specifick.CodeID)=" & !CodeID & ") AND ((Specifick.Long)=" & !Long & ") AND ((Specifick.Diametr)=" & !Diametr & "))" Do Until .EOF If Not rs.NoMatch Then rs.Edit If Len(KolvoTmp) > 0 Then rs![Kol-vo] = ![Kol-vo] rs!Volume = !Volume rs!Volume_All = !Volume_All Else rs.Delete End If rs.Update Else rs.AddNew rs!docId = GDocId rs!CodeID = !CodeID rs!Long = !Long rs!Diametr = !Diametr rs![Kol-vo] = ![Kol-vo] rs!Volume = !Volume rs!Volume_All = !Volume_All rs.Update End If .MoveNext If Not .EOF Then rs.FindNext "(((Specifick.CodeID)=" & !CodeID & ") AND ((Specifick.Long)=" & !Long & ") AND ((Specifick.Diametr)=" & !Diametr & "))" End If Loop End If rs.Close .Close End With Set rs = CurrentDb().OpenRecordset(str) Set rsTmp = CurrentDb().OpenRecordset(strTmp) With rs If Not .EOF Then rsTmp.FindFirst "(((tmp_Specifick.CodeID)=" & !CodeID & ") AND ((tmp_Specifick.Long)=" & !Long & ") AND ((tmp_Specifick.Diametr)=" & !Diametr & "))" Do Until .EOF If rsTmp.NoMatch Then .Delete End If .MoveNext If Not .EOF Then rsTmp.FindNext "(((tmp_Specifick.CodeID)=" & !CodeID & ") AND ((tmp_Specifick.Long)=" & !Long & ") AND ((tmp_Specifick.Diametr)=" & !Diametr & "))" &nb
Ответить
|