Index/Primary Key Error Handler

  • Thread starter Thread starter Terrence Carroll
  • Start date Start date
T

Terrence Carroll

I have a multiform set-up and I need an error handler for when the user goes
into the subform and inadvertently attempts to enter a new record on the
form. I can not just set the add record property on the form to "no" as
there are times when the user may need to add a record. Right now I am
getting the "Index or Primary Key can not contain a null value!" message. I
would like the user to be able to exit the record without having to close the
form without saving. Right now the standard Index/Primary key message
essentially locks up the form because the use can only click OK which causes
the primary key message to return or exit out in which case the changes made
by the user are not saved.
 
Use the BeforeInsert event of the subform.
If the matching field on the main form IsNull(), cancel the event.

This notifies the user *before* they go to the trouble of filling in the
subform record.
 
Back
Top