BeforeUpdate issue - Runtime (error 2115)
I have written the following query:
Private Sub Size_Sqft_BeforeUpdate(Cancel As Integer)
Me!Size_Sqft = Nz(Me!Size_Sqft, 0)
End Sub
But while removing the zero in the field to make it null, I am getting the foll开发者_StackOverflow社区owing error:
Runtime error 2115
Macro and function set to before update and validation rule property for this field is preventing manual data entry screen for company from saving the data in the field.
You have to put that code in the AfterUpdate event of that field.
I know this is an old thread, and has already been answered, but there is another solution that doesn't require several writes back to your database. I'm adding it in case someone else comes across this question.
Private Sub ControlName_BeforeUpdate(Cancel as integer)
If isValid(Me.ControlName.Value) = False Then
Cancel = True
Me.ControlName.Undo
End If
End Sub
Private Function isValid(ByVal...) as boolean
' validate control value here
End Function
精彩评论