have a subform within a form. If the total payments in the subform is > the DolAmt in the form, i would like to set the payment in the subform to 0. I do a recalc to ensure that the total payments showing in the main form (which - Sum(payments) in subform gets recalculated. This is all happening after an Apply check has been clicked to indicate that the payment should be applied to the Dolamt in the main form
But I keep getting the msg:
Error: The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing the database from saving the data in the field
on the line where I reset me.Payment = 0 after the Cancel = True.
There are no validation rules on the payment field
Any advice would be much appreciated!!
Code is below
Private Sub Apply_BeforeUpdate(Cancel As Integer)
If Me.Apply = True Then
If Me.AmtDue > [Forms]![Customer Payment Form]![DolAmt] Then
Me.Payment = [Forms]![Customer Payment Form]![DolAmt]
Else
Me.Payment = Me.AmtDue
End If
Me.Paid = Me.PrePaid + Me.Payment
Else
Me.Payment = 0
Me.Paid = Me.PrePaid
End If
Me.Recalc
If Me.TotPayment > [Forms]![Customer Payment Form]![DolAmt] Then
MsgBox "Total applied cannot be greater than check amount!", vbExclamation, ""
Cancel = True
Me.Payment = 0
Me.Paid = Me.PrePaid
Me.Recalc
End If
End Sub
Private Sub Payment_BeforeUpdate(Cancel As Integer)
If Me.AmtDue < 0 Then
MsgBox "Total payment cannot be greater than amount due!", vbExclamation, ""
Cancel = True
End If
If [Forms]![Customer Payment Form]![FraCheckCredit] = 1 Then
If Not IsNull(Me.Payment) Then
If (Me.TotPayment) + Me.Payment - Me.Payment.OldValue > [Forms]![Customer Payment Form]![DolAmt] Then
MsgBox "Total applied cannot be greater than check amount!", vbExclamation, ""
Cancel = True
End If
End If
Else
If (Me.TotPayment) + Me.Payment - Me.Payment.OldValue > Forms![Customer Payment Form]![Customer Payment Apply Credits subform].Form![Amount] Then
MsgBox "Total applied cannot be greater than credit amount!", vbExclamation, ""
Cancel = True
End If
End If
End Sub
But I keep getting the msg:
Error: The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing the database from saving the data in the field
on the line where I reset me.Payment = 0 after the Cancel = True.
There are no validation rules on the payment field
Any advice would be much appreciated!!
Code is below
Private Sub Apply_BeforeUpdate(Cancel As Integer)
If Me.Apply = True Then
If Me.AmtDue > [Forms]![Customer Payment Form]![DolAmt] Then
Me.Payment = [Forms]![Customer Payment Form]![DolAmt]
Else
Me.Payment = Me.AmtDue
End If
Me.Paid = Me.PrePaid + Me.Payment
Else
Me.Payment = 0
Me.Paid = Me.PrePaid
End If
Me.Recalc
If Me.TotPayment > [Forms]![Customer Payment Form]![DolAmt] Then
MsgBox "Total applied cannot be greater than check amount!", vbExclamation, ""
Cancel = True
Me.Payment = 0
Me.Paid = Me.PrePaid
Me.Recalc
End If
End Sub
Private Sub Payment_BeforeUpdate(Cancel As Integer)
If Me.AmtDue < 0 Then
MsgBox "Total payment cannot be greater than amount due!", vbExclamation, ""
Cancel = True
End If
If [Forms]![Customer Payment Form]![FraCheckCredit] = 1 Then
If Not IsNull(Me.Payment) Then
If (Me.TotPayment) + Me.Payment - Me.Payment.OldValue > [Forms]![Customer Payment Form]![DolAmt] Then
MsgBox "Total applied cannot be greater than check amount!", vbExclamation, ""
Cancel = True
End If
End If
Else
If (Me.TotPayment) + Me.Payment - Me.Payment.OldValue > Forms![Customer Payment Form]![Customer Payment Apply Credits subform].Form![Amount] Then
MsgBox "Total applied cannot be greater than credit amount!", vbExclamation, ""
Cancel = True
End If
End If
End Sub