MS-Access VBA: How to set field value back to old value if Form_Error event is triggered

Hello World

I've had a request to return the value entered in a field by user to the previous value if it does not pass data validation criteria.

Where I can trap this in the BeforeUpdate event I am using a global variable to store the .oldvalue and then reassigning in the AfterUpdate event.

However data validation triggered by table structure exceptions (such as text in a number field) trigger the Form_Error event before the BeforeUpdate event and the Form_Error event does not relate to a specific field that I can store as an old value.

I could get around this by setting up the table as completely free text in all fields with nulls allowed, such that there would be no Form_Error event triggered and all validation handled in BeforeUpdate

Is this really the way I need to go about this? It seems odd to have to set up a nonsense table structure to handle errors but I'm struggling to come up with another method

Brad

I'm turning this comment into an answer. This is the gist of how to revert from the Form_Error.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Undo
    Response = 0
End Sub

You could do more like display a message on the screen saying what you did to you user then hide it on a timer event. Just something so their not sure why their data went away.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

MS-Access VBA:如果触发了Form_Error事件,如何将字段值设置回旧值

来自分类Dev

MS-Access VBA:如果触发了Form_Error事件,如何将字段值设置回旧值

来自分类Dev

Use jQuery to set value of hidden field in a form and submit the value

来自分类Dev

How To Access The Value in HashTable

来自分类Dev

MS Access VBA IF()

来自分类Dev

MySQL的PHP变数(SET'$ field'='$ value')

来自分类Dev

set value of input field by php variable's value

来自分类Dev

How to pass a value back into a class in Java?

来自分类Dev

Capybara form value set with cocoon

来自分类Dev

Int()函数MS Access VBA

来自分类Dev

MS ACCESS vba-错误

来自分类Dev

MS Access VBA 运行查询

来自分类Dev

Set the value in a toggle-field on Sencha-touch

来自分类Dev

Unable to set field value via ReflectionUtils.setField

来自分类Dev

使用“ this.field = value”与“ field = value”

来自分类Dev

PhantomJS; If I set a variable inside page.evaluate(), how can I access the value of that variable outside of page.evaluate()

来自分类Dev

带VBA的MS Access链接表

来自分类Dev

MS Access中VBA代码的继承

来自分类Dev

多参数IsNull函数MS Access VBA

来自分类Dev

SQL语法问题MS Access VBA

来自分类Dev

MS-Access:使用vba移至NavigationControl

来自分类Dev

MS Access VBA:如何清除图像控件?

来自分类Dev

是/否字段上的MS Access VBA Dlookup

来自分类Dev

MS Access查询未从VBA接收参数

来自分类Dev

MS Access VBA:OpenRecordSet返回什么?

来自分类Dev

MS Access VBA,SQL脚本:In(),<>和AND语法

来自分类Dev

使用VBA显示MS Access报告

来自分类Dev

MS ACCESS VBA按案例订购的时间

来自分类Dev

MS Outlook会干扰Access vba过程

Related 相关文章

热门标签

归档