Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 12th, 2005, 11:27 AM
MushMouse MushMouse is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 6 MushMouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 4 sec
Reputation Power: 0
Error: The macro or function set to the BeforeUpdate or ValidationRule property for t

I 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

Reply With Quote
  #2  
Old July 12th, 2005, 03:17 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
What is the purpose of using the BeforeUpdate Event in the Apply check box? I would think that using the AfterUpdate will correct the condition. The apply check box is a true/false condition and your msgbox is trying to cancel before it is even updated. If you need to use the before update event for the check box then move the msgbox to after update.

lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Error: The macro or function set to the BeforeUpdate or ValidationRule property for t


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway