Deleting record from junction table on continuous form

Jupie23

Registered User.
Local time
Yesterday, 19:16
Joined
Nov 9, 2017
Messages
90
I have a continuous form with all records from the table Main. It's purpose is for a supervisor to be able to correct a record if needed. Each record could potentially also have data on 2 related junction tables. I have added 2 Edit buttons on each record/row on the continuous form in case they need to add or remove something from the junction tables.

The Edit buttons open up a form with Main as the record source, which has a continuous child subform based on the junction table. There are comboboxes that show what is already present and a blank one to add new ones, and then behind each combobox is a delete button.

One of them is working how I'd like, to delete only the one item from the junction table where they clicked Delete. It says "You are about to delete 1 record." and only deletes from the junction table. The other one is deleting the record from the junction table as well as from the Main table. The incorrect one says "Relationships that specify cascading deletes are about to cause 1 record in this table, along with related records to be deleted."

I do have cascading deletes set up in the relationship, because I wanted anything deleted from Main to also delete from the junction tables. But I don't want anything deleted from the junction tables also deleted from Main. Why is one doing it and one is not? The relationship is exactly the same. I have compared the working subform to the non working one and cannot find any differences. What am I missing? Is there a better way to do this so they aren't deleting things by accident? Or a better way to let them edit a record on Main as well as add or remove things from junction tables? The junction tables only have ID numbers and not descriptions, so they need a something like a combobox that shows them the description of what they are adding or removing.

Any help would be greatly appreciated!
 
depends on what query you have on the second button.
 
Do you mean the Edit button on the first form or the Delete buttons?

For the Delete buttons I just used the wizard and have a macro.
 
from the multiple delete from junction.
 
I have a continuous form with all records from the table Main. It's purpose is for a supervisor to be able to correct a record if needed. Each record could potentially also have data on 2 related junction tables. I have added 2 Edit buttons on each record/row on the continuous form in case they need to add or remove something from the junction tables.

The Edit buttons open up a form with Main as the record source, which has a continuous child subform based on the junction table. There are comboboxes that show what is already present and a blank one to add new ones, and then behind each combobox is a delete button.

One of them is working how I'd like, to delete only the one item from the junction table where they clicked Delete. It says "You are about to delete 1 record." and only deletes from the junction table. The other one is deleting the record from the junction table as well as from the Main table. The incorrect one says "Relationships that specify cascading deletes are about to cause 1 record in this table, along with related records to be deleted."

I do have cascading deletes set up in the relationship, because I wanted anything deleted from Main to also delete from the junction tables. But I don't want anything deleted from the junction tables also deleted from Main. Why is one doing it and one is not? The relationship is exactly the same. I have compared the working subform to the non working one and cannot find any differences. What am I missing? Is there a better way to do this so they aren't deleting things by accident? Or a better way to let them edit a record on Main as well as add or remove things from junction tables? The junction tables only have ID numbers and not descriptions, so they need a something like a combobox that shows them the description of what they are adding or removing.

Any help would be greatly appreciated!

Jupie, if you get the wrong message ("Relationships that specify cascading deletes are about to cause 1 record in this table, along with related records to be deleted.") on attempting to delete from a junction table it is most probably because your "join" is in the wrong direction. This message should never appear in the relationship on the "infinity" side ( i.e. junction table side). Check the relationship again. Your "Main" table should be on the left and the first radio button for joins (only include rows from the two tables where joined fields are equal) should be selected.

Best,
Jiri
 
i think thats what he has right now, basing on the first dekete he performed in one junction, he could have deleted the master as well.
 
Both relationships appear to be the same. Please see attached images. Thank you!
 

Attachments

  • Checklist Relationship.jpg
    Checklist Relationship.jpg
    47.9 KB · Views: 93
  • SQ Relationship.jpg
    SQ Relationship.jpg
    47.5 KB · Views: 108
I changed my delete button from the wizard created macro to this:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

and it seems to do the trick. Thank you!
 

Users who are viewing this thread

Back
Top Bottom