K
Ken Snell [MVP]
Let's change the If statement (I should have noted this earlier, sorry):
If rst.RecordCount > 0 Then
rst.MoveFirst
rst.FindFirst "Paid = false"
Do While rst.EOF = False
InvNo = Forms!payments!PaymentSubform!InvoiceID
InvTot = Forms!payments!PaymentSubform!AmtRemaining
If InvTot < PmtAmt Then
rst.Edit
rst!Paid = True
rst!AmtRemaining = "0"
rst.Update
PmtAmt = PmtAmt - InvTot
rst.MoveNext
ElseIf InvTot = PmtAmt Then
rst.Edit
rst!Paid = True
rst!AmtRemaining = "0"
rst.Update
Exit Do
ElseIf InvTot > PmtAmt Then
rst.Edit
rst!AmtRemaining = InvTot - PmtAmt
rst.Update
Exit Do
End If
Loop
End If
rst.Requery
Set rst = Nothing
If rst.RecordCount > 0 Then
rst.MoveFirst
rst.FindFirst "Paid = false"
Do While rst.EOF = False
InvNo = Forms!payments!PaymentSubform!InvoiceID
InvTot = Forms!payments!PaymentSubform!AmtRemaining
If InvTot < PmtAmt Then
rst.Edit
rst!Paid = True
rst!AmtRemaining = "0"
rst.Update
PmtAmt = PmtAmt - InvTot
rst.MoveNext
ElseIf InvTot = PmtAmt Then
rst.Edit
rst!Paid = True
rst!AmtRemaining = "0"
rst.Update
Exit Do
ElseIf InvTot > PmtAmt Then
rst.Edit
rst!AmtRemaining = InvTot - PmtAmt
rst.Update
Exit Do
End If
Loop
End If
rst.Requery
Set rst = Nothing