Before Update Event Undo problem

J

jazzbah

I'm trying to program the Before Update Event for a text box on my
form. I seem to be getting thwarted by a system message like, "The
value you entered isn't valid for this field" and leaves the focus
remaining in the text box, with the offending text (or in this case a
date) in tact with the cursor blinking in the field. I have tried
using the me.txtOrderDt.undo, but it seems that the system message
overrides this and the undo event does not happen. Ideally, I would
like to see the text box undone and returned to the existing value
that was in the box before the invalid text was entered. Can I bypass
this system message? How do I achieve what the user could achieve if
they pressed the Esc key?
Thanks
David G
 
K

kingston via AccessMonster.com

What exactly is preventing the update? Is it because the input is of the
incorrect type or is it that the data is invalid? Does the message result
from validation you are performing? You should be able to do a Cancel = True
in your BeforeUpdate event, but this will not revert the input. Consider the
case if it did - the user would enter in bad data that he thought was good
and the program would automatically reset it. Unless he knew that the
program was supposed to do this, he might suspect that the application was
broken. In cases where the user is trying to enter bad data that he thinks
is good, he will definitely think that the application is broken. I suggest
that you add an alert message that tells the user the data is bad and to
force him to fix it, perhaps via the Escape key. If your problem is a result
of a validation that you do, you could allow the update and then reset the
value using the property OldValue.
 
J

jazzbah

What exactly is preventing the update? Is it because the input is of the
incorrect type or is it that the data is invalid? Does the message result
from validation you are performing? You should be able to do a Cancel = True
in your BeforeUpdate event, but this will not revert the input. Consider the
case if it did - the user would enter in bad data that he thought was good
and the program would automatically reset it. Unless he knew that the
program was supposed to do this, he might suspect that the application was
broken. In cases where the user is trying to enter bad data that he thinks
is good, he will definitely think that the application is broken. I suggest
that you add an alert message that tells the user the data is bad and to
force him to fix it, perhaps via the Escape key. If your problem is a result
of a validation that you do, you could allow the update and then reset the
value using the property OldValue.

Thanks for your response,
I didn't even realise that I got a response. I'm a user groups
newbie.
OK, it was the system error message in response to invalid data.
which overwrote my msgbox.
I did some further research and it was pointed out to me that I needed
to use the Form_Error event.
I could then trap the error with that event and the Before Update then
worked perfectly.
Thanks again
David G
 
Top