Index/Primary Key Error Handler

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.
 
A

Allen Browne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top