Hi, everyone! I've searched the forums for other 2115 questions and can't find one that suits my particular question.
I've got a data entry form with some dates. Code validates that the dates are in logical order (not processed before received, for instance). If a date order error is found, I want the form to remove the date the user entered and give them a message box. The message box comes up just fine, but on trying to remove the incorrect date, I get the 2115 error. (Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.)
The code that runs is:
blnAddMode is an identifier for me to tell the code further down if this is a new record. The date field txtSite2Rec has no validation rule, and I can't set zero length to Yes because it's a date field. However, if I remove the date manually, the form accepts that just fine. I tried .Undo instead and it stopped me from getting the error, but the erroneous date remained in the form. Help?
I've got a data entry form with some dates. Code validates that the dates are in logical order (not processed before received, for instance). If a date order error is found, I want the form to remove the date the user entered and give them a message box. The message box comes up just fine, but on trying to remove the incorrect date, I get the 2115 error. (Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.)
The code that runs is:
Code:
Private Sub txtSite2Rec_BeforeUpdate(Cancel As Integer)
blnAddMode = False
If DatePart("yyyy", txtSite2Rec) <> 2006 Then
MsgBox "Please check the Site 2 Receipt date."
ElseIf Not IsNull(txtSite1Sent) And txtSite2Rec < txtLodiSent Then
MsgBox "Site 2 Receipt cannot be before Site 1 Sent Date."
txtSite2Rec = Null
Exit Sub
End If
End Sub
blnAddMode is an identifier for me to tell the code further down if this is a new record. The date field txtSite2Rec has no validation rule, and I can't set zero length to Yes because it's a date field. However, if I remove the date manually, the form accepts that just fine. I tried .Undo instead and it stopped me from getting the error, but the erroneous date remained in the form. Help?