Getting Error - Trying to delete a record (1 Viewer)

henryihunter1954

Registered User.
Local time
Yesterday, 20:14
Joined
Mar 2, 2016
Messages
89
I have a form that also has a subform.

I placed a (Delete) button on the form - Main form.
When I press the button to delete that particular record, I get the error:

The record cannot be deleted or changed because Table 'Contract Product Details' includes related records.

Does anyone have a solution for this error?
Have I set something up in my design that keeps me from deleting the record?

Thanking you all in advance for assistance.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:14
Joined
Aug 30, 2003
Messages
36,124
Yes, in your relationships. You're requiring a field in the detail table be present in the main table (which is a good thing). You can add cascade delete in referential integrity if you're okay with the related detail records being deleted when you delete the main record.
 

henryihunter1954

Registered User.
Local time
Yesterday, 20:14
Joined
Mar 2, 2016
Messages
89
pbaldy:

Thank you for your response.
This is an amazing group when it comes to helping those of us who really need it.

I will take your advice: Add cascade delete in referential integrity.
Now, even though I don't know what that is at this time, I will research it and see if I can totally follow this instruction.

Thank you so much.
I will return to let you know how it goes.

Thanks again.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 23:14
Joined
Jan 23, 2006
Messages
15,379
The error is saying ---you are trying to delete a record on the main form that has related record(s) on the subform. If you delete that main form record, you will have an orphan on the subform--And I'm not going to do that.

As Paul indicated you can delete the main form record and all of its children if you use cascade delete.

Good luck with your project.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:14
Joined
Aug 30, 2003
Messages
36,124
No problem. I don't feel like I've explained it very well. Time for lunch, so that's probably the problem. :p

If you deleted the main record alone, you leave orphan records in the detail table (child records with no parent record). For example, if you deleted invoice 123 and had an invoice detail table with line items for invoice 123, they get orphaned. Depending on your situation, you generally want to either prevent the deletion of the parent record or cascade delete the child records.
 

henryihunter1954

Registered User.
Local time
Yesterday, 20:14
Joined
Mar 2, 2016
Messages
89
Thank you all.
Maybe I stated my problem incorrectly too.
I did not intend to delete the form itself. I need to delete the record.
But I am following your instructions.
I think I see when the relationship is created, I need to click on Cascade delete also.
Going to give it a try.
Thanks to you all again.
Great help.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:14
Joined
Aug 30, 2003
Messages
36,124
I think we both understood you were trying to delete a record.
 

henryihunter1954

Registered User.
Local time
Yesterday, 20:14
Joined
Mar 2, 2016
Messages
89
pbaldy:

I followed the instructions.
I went to the relationships.
Clicked on the relationship between the 2 tables.
Edited it. Clicked on the Cascade Delete.

Like a charm...it worked with ease.

Thanking you all so very much.

I'd shown my project to the lady that is going to use it.
She continued to test it but putting in same information each time.
First thing she said to me, "How do I delete this stuff that I just keyed in?"
That is when I realized that I needed to perform a delete on a record.

Great Help from you all.
Thank you so very much.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:14
Joined
Aug 30, 2003
Messages
36,124
Happy to help!
 

Users who are viewing this thread

Top Bottom