Hello everyone
I took another approach because I found it easy to grasp.
Code:
StrSql = "Select max(Aut), remain, deposit, Total_deposit  from  Trans where  acquit  = 0 And  id = 1 Group by Item_Id"
Set Rs = Cnn.OpenRecordset(StrSql)
Dim Payment As Integer
Dim Balance As Integer
Payment = 80
Rs.MoveFirst
Balance = Payment - Rs("remain")
Do While Balance > 0
Balance = Payment - Rs("remain")
Debug.Print Balance
If Balance > 0 Then
Rs!deposit = Rs!deposit + Balance
Rs.UpdateBatch
Payment = Balance
Rs.MoveNext
End If
Loop
Name:  06-04-2021 00-41-31.png
Views: 82
Size:  18.5 KB