开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜