I have a form that has a before update function that is checking the validity of the data entered. My problem is this. If the user closes the form from the close box at the top of the form the before update function kicks in to check the data (this is good). If any of the data poops out the before update function cancels the entry. The next thing that happens is the problem - Access puts up a screen that says "You can't save this record at this time." It then goes on to warn the user that data changes made will not be saved. I attempted to use the form error event to catch this error text and replace it with something less confusing to complete novices. (my users) But my attempts failed. Its throwing an application or object defined error. How can I catch this error and replace its description with my own?
I’m not sure what the answer is, so probably the best thing would be to prevent the error happening in the first place. I haven’t had the same problem with any of my forms that check updates (despite trying to induce one now). How are you canceling the update? Is it on an update or insert that the error occurs (or both)? Have you tried popping in a breakpoint and stepping through the Before Update code? Does the error occur whether the data is valid or not? Sorry for all the questions, I just can't get mine to error. Thought it might have something to do with Keys but that didn't work either....
I'm cancelling the update with cancel = true in the beforeUpdate event. This is a bound form if that matters. If the data is valid the problem does not occur probably because my tests for problem data never fire the cancel event. The error msg isn't fatal in the sense that it borks the app; it's just confusing. Maybe my flow of control for the form is screwy - I'm using the standard record navigation buttons at the bottom of the form. With a standard close box for the form. Basically that beforeUpdate event is supposed to catch data entry errors; on catching one it warns the user and asks if they want to fix that entry or undo the record. This all works great if the user makes an error and tries to navigate to another record. It falls down when the user attempts to simply close the form with a data entry error on the page. That's when Access throws its own errors for data validation and tells the user that it can't save the current record because of the error and then asks if it should close the form anyway. That's what I'm trying to catch.
Okay, I can replicate it using the Cancel = true method. Got to admit, I don't really use the cancel variable so I don't know how it differs or why it should throw up problems, however I do use me.undo as way of canceling any updates and it seems to work fine, with no errors. Might be worth a trial if no one is able to help intercepting Application errors.