Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Lost after Form Validation Events

Status
Not open for further replies.

NattyP

MIS
Sep 1, 2001
45
JM
The following was posted before, but the response posts are not helping me.

I have the exact same problem and is re-asking the question?

....

I have validation in the Before_Update event. Works great except for the unload of a form.
Scenario -
1) user changes data in a field
2) clicks the X on the form to close the form, triggering the unload event
3) prior to the unload event, the before_update event occurs
4) in this scenario, the user entered invalid data, the before_update event is cancelled (cancel = true) due to the validation
5) for some reason, the form_error event occurs - displaying a message box "You can't save this record at this time - do you want to close and lose your data?" (error 2169). If you click Yes, the form closes and all information is undone. If you answer No, the form redisplays with the data in it. This is the path I would like to take without having to deal the MS Access's not so
user-friendly at all. I tried to intercept to place my own message by setting the RESPONSE property of the form_error event to acDataErrContinue. The problem is - it takes the path as if you had answered "Yes" to the earlier question.

I would really like the data to stay on the screen giving the user the chance to correct the problem before exiting the screen.
 
I think the best way to handle this is to remove the ControlBox (in Form's Properties) and use a 'Close' button, calling Docmd.acCmdSaveRecord, which triggers update. You can then use a form-scoped variable and upon return to the Close button's procedure, give you're own message or deal with the invalid data in your own way. Here you have more control.

Not much can be done for the user doing Ctrl-F4 to close the form, but hey, if the user is really trying to get around the friendly buttons you've worked so hard to create for them, then they deserve a nasty error message.
--Jim

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top