If [Forms]![付款记录1]![可用金额] > 0 Then
If Me.付款状态 = True Then
If Me.总金额 <= [Forms]![付款记录1]![可用金额] Then
Me.已付金额 = Me.总金额
Me.需付金额 = Me.总金额 - Me.已付金额
Me.结算日期 = Date
Me.备注 = "从" & [Forms]![付款记录1]![付款金额] & "扣除"
[Forms]![付款记录1]![可用金额] = [Forms]![付款记录1]![可用金额] - Me.总金额
Me.[Forms]!欠款记录查询.Requery
Else
Me.已付金额 = [Forms]![付款记录1]![可用金额]
Me.需付金额 = Me.总金额 - Me.已付金额
Me.备注 = Date & "付了" & [Forms]![付款记录1]![可用金额]
End If
End If
End If