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
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] 删除。
我来说两句