delete a record in a child table when a field is changed to null

  • Thread starter Jonathan S via AccessMonster.com
  • Start date
J

Jonathan S via AccessMonster.com

Thanks to all who have helped in the past.

I would like to be able to delete a field on a subform and have the related
record in a child table deleted at the same time.

I have three tables; tblTrips with a one to many relationship to tblRetreive
which has a one to many reletionship to tblSamples.


I have a mainform (frmTrips) with a subform (frmRetrieveSbfrm) , as well as
another form (frmSamples).

Both Tbl Retrieve and tblSamples have a field called sample_id. I have used
autonumbers as primary keys in both tables and my relationship is drawn on
sample_id.

When a sample id is entered into subform frmRetrieveSbfrm the form frmSamples
opens and allows you to enter sample info. This all work fine.

If I discover that a sample was entered in error, I would like to be able to
delete the sample_id field on frmRetrieveSbfrm and have the related record in
tblSamples deleted also.

Currently when I delete the sample_id field on frmRetrieveSbfrm, It leaves
the child record in tblSamples which violates referential integrity.

I would prefer to attach this code to an event on the frmRetrieveSbfrm
sample_id field, but I am unshure which event to use as well as how to write
the code. I thought to use the ondirty event, but how do I ge around the
event firing when a sample_id is entered?

I suspect this code will involve the use of a recordset, but I am unshure
how to write it.

Thanks
Jonathan
 

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