How to catch data errors during deletion

Johnny Redneck

New member
Local time
Tomorrow, 00:46
Joined
Apr 28, 2009
Messages
8
Hi,
I'm trying to replace all access error messages with my own custom ones. I'm stuck in one area only and would appreciate any help. In the runtime, I want to allow users to select records using the far left "record selection" column of a dataSheet and permit deletion via the keyboard "Delete" key just as you would in full Access.
I have setup custom "Do you want to continue..." etc. but if one or more of the records cannot be deleted because of referential rules, I can't seem to figure out how to catch the error associated with this scenaio. So I either get the standard Access message ("This record cannot be deleted or changed because...") or suppress it and have nothing to show.
Thanks in advance
 
trap it by testing for the appropriate code using the forms error method, i think
 
Thanks for responding. I would have thought so too!
A delete button on the main form (records I'm deleting are on sub-form) deletes highlighted record using "Me.Workers_subform.Form.Recordset.Delete" which raises an error if the record may not be deleted due to referential integrity issues. I can catch this error in the button's same Click event and all works well.
But when I select one or more records directly in the sub-form, the same error isn't caught by the Form_Error event. I can catch the error under the Form_Delete event but the err code is "0", so no information is available. I suspect that I need to look at a different error object but so far no joy.
I'm really puzzled by this!
 
you need the error event, and i think you use the accesserror argument, rather than the err object
 
And you need to use the subform's error event and not the click event of the button on the main form
 
My long explanations may have clouded the issue. The problem is that when deleting directly in the sub-form by selecting one or more records with the datasheet's record selection column and pressing the keyboard Delete key, the error causes by referential integrity (duplicate key) is only caught by the sub-form's Form_Delete event and then it does not return a DataErr but instead just an Err (value = 0). I've tried leaving out all error handling except in the sub-form's Form_Error section but the error is just not caught there.

I've looked at AccessError but I can't see how I would use this.
 

Users who are viewing this thread

Back
Top Bottom