Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: The macro or function set to the BeforeUpdate or ValidationRule

Status
Not open for further replies.

MushMouse

Programmer
Mar 29, 2004
65
US
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
 
I've gotten this error myself, and like you, have no events or rules applied. I ran repair and update, and it seemed to solve the problem.

As best as I can tell, it happens when I'm doing a lot of development/testing, and really stressing the application.

Hope that helps.
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top