From: Terrence Carroll on
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.
From: Allen Browne on
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Terrence Carroll" <TerrenceCarroll(a)discussions.microsoft.com> wrote in
message news:7A5151D4-6330-4F36-B4AB-0597C23DC6C1(a)microsoft.com...
> 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.