Update Error Trapping and Clearing

  • Thread starter Thread starter Nick K.
  • Start date Start date
N

Nick K.

I have an Access 2003 form that I am viewing in Datasheet view. A row has
several fields, some with combo boxes. I noticed that when I mistakenly
click outside the row, as expected, the row will attempt an update. When
referential integrity prevents the row from updating, I get an error message
"You cannot add or change a record because a related record is required in
table X"

My problem is that I want the error cleared after it happens. In some cases
I want to Refresh a particular field that has a combo box. I cannot do a
refresh after the error happens, I just get the same error message as above.

How can I trap and clear the error, would that be done using VBA?

Also, say I wanted to clear the row without entering anything at all (after
I attempted to enter row data). The only way I know to do this is to close
the form and open it again. Is there a way to clear the row without doing an
update and carrying on with the form?
 
This is an engine-level error, so use the Error event of the form to trap
this error.

Requerying or refreshing the form will generate the error if the record
cannot be saved, but you are just wanting to requery the combo, I think?
Me.[NameOfYourComboHere].Requery
 
Back
Top