Unanswered: (Access) Clearing a field after validation rule pop-up window
I have a form in which there are fields that have validation rules for the quantity and types of characters that are entered by the people on the production floor. The operators are wanting me to refine this so that if they accidentally enter or scan the wrong information, the affected field will automatically be cleared of the previously-entered contents (after they clear the validation error pop-up window). How can I accomplish this?
I tried out your recommended code, and I understand your intent of the code; but I actually want to keep all of the other current fields on the form as-is....I just want to only clear the entered text that relates specifically to the field that had the validation error.
For example, on the top of my form the operators enter their shift number, part number and other credentials. Then lower down on the form, there are two fields to enter serial number and "Pass/Fail". If they accidentally scan the wrong barcode for the serial number field, or accidentally type in the wrong character on the "Pass/Fail" field, I want this incorrect information to automatically be deleted after they acknowledge the validation pop-up screen. However, the info entered above (shift number, part number, etc.) needs to remain static. Thanks in advance.
This is what exactly what I meant by the first example (restoring the old status of the field when the entered value is wrong).
Instead of setting up the validation rule in the property sheet write code in the lost_focus() Event procedure of the field to pop up a message when the entered value is not acceptable and to restore the old status of the field.
If me![quantity] < 1 or me![quantity]>100 then
msgbox "Valid Value Range: 1 - 100"
Me![Quantity] = Me.[Quantity].OldValue