我编写了以下查询:
Private Sub Size_Sqft_BeforeUpdate(Cancel As Integer)
Me!Size_Sqft = Nz(Me!Size_Sqft, 0)
End Sub但是,在移除字段中的零以使其为空时,我将得到以下错误:
运行时错误2115
此字段的宏和函数设置为“前更新和验证规则”属性,以防止公司手动数据输入屏幕保存该字段中的数据。。
发布于 2009-10-12 11:43:52
您必须将该代码放在该字段的AfterUpdate事件中。
发布于 2014-01-21 16:46:17
我知道这是一个旧线程,并且已经被回答了,但是还有另一个解决方案不需要多次写回您的数据库。我加起来是为了防止其他人遇到这个问题。
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 Functionhttps://stackoverflow.com/questions/1553833
复制相似问题