Answered by:
Remove Pesky Cascading Delete Message

Question
-
Hello:
I have a form/subform relationship, and I want to delete child records when I delete the parent record. I don't want the annoying message that comes up every time I delete a parent record. How do I remove it?
But I don't want to delete all warning messages.
Thanks!
Here's the message:
Rich Locus, Logicwurks, LLC
Wednesday, September 30, 2020 4:14 PM
Answers
-
You might like to take a look at DeleteDemo.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
This little demo file illustrates how the deletion of a record or records via a form can be customized to display your own confirmation dialogue, or to delete without confirmation. It also illustrates how to mark records as deleted, which allows for later recovery if necessary.Ken Sheridan, Stafford, England
- Marked as answer by RichLocus Thursday, October 1, 2020 7:20 PM
Wednesday, September 30, 2020 5:36 PM -
is the user using the built in delete command? (say click on record selector, and then hits del key?).
if this is a code/button, then you can go:
docmd.SetWarnings false
code here to delete
docmd.SetWarnings True ' you should turn this back on
Now, you can in code startup, or in fact just about anyplace execute the above setWarnings false. Just keep in mind that once you execute this command - it "sticks", and remains in effect. So, if you do this, then users will not get nor see warnings anymore.
So, if they hit a key to delete a record, they will not get ANY prompts.
This really depends on if you are providing a button to delete, or using built in delete features. If you using built in delete from ribbon or del key, then this is somewhat dangerous, since users will not see nor get any kind of prompts with warnings turned off.
Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada
- Marked as answer by RichLocus Thursday, October 1, 2020 7:17 PM
Thursday, October 1, 2020 1:08 AM
All replies
-
You might like to take a look at DeleteDemo.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
This little demo file illustrates how the deletion of a record or records via a form can be customized to display your own confirmation dialogue, or to delete without confirmation. It also illustrates how to mark records as deleted, which allows for later recovery if necessary.Ken Sheridan, Stafford, England
- Marked as answer by RichLocus Thursday, October 1, 2020 7:20 PM
Wednesday, September 30, 2020 5:36 PM -
If you are deleting the parent records using a form or vba, it is simple to disable waring messages temporarily then restore them afterwards
However, if you are deleting directly from the parent table, I'm not sure it is possible to do what you ask.
In any case, it is usually a bad idea to delete data. Much better to flag unwanted data as inactive so it can be subsequently restored if needed. I suspect that is what Ken is referring to
- Edited by isladogs52 Wednesday, September 30, 2020 8:36 PM
Wednesday, September 30, 2020 8:33 PM -
is the user using the built in delete command? (say click on record selector, and then hits del key?).
if this is a code/button, then you can go:
docmd.SetWarnings false
code here to delete
docmd.SetWarnings True ' you should turn this back on
Now, you can in code startup, or in fact just about anyplace execute the above setWarnings false. Just keep in mind that once you execute this command - it "sticks", and remains in effect. So, if you do this, then users will not get nor see warnings anymore.
So, if they hit a key to delete a record, they will not get ANY prompts.
This really depends on if you are providing a button to delete, or using built in delete features. If you using built in delete from ribbon or del key, then this is somewhat dangerous, since users will not see nor get any kind of prompts with warnings turned off.
Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada
- Marked as answer by RichLocus Thursday, October 1, 2020 7:17 PM
Thursday, October 1, 2020 1:08 AM -
Hi Rich,
Albert's suggestion is a good one.
You actually can run a macro to disabled the warnings during start-up. But most developer doesn't want to do that as it entails future problems.
If your databases design concern is not about data loss. That is to say, all data/records are imported from another source where there are no chances of unwanted deletions. You are safe to create a start-up macro to disabled the warnings or you can just simply set the warning off in the Access Options.
However, if a user create or open a Select query, this query can be deleted without warnings.
It's a good idea to delete records on a Form event or control. That way, you can control the warnings whenever you need it back.
HTH.
Thursday, October 1, 2020 7:00 AM -
Albert:
There were some good suggestions from the other responders, and I gave them all a + Vote, but your answer is probably the easiest.
Thanks,
Rich Locus, Logicwurks, LLC
Thursday, October 1, 2020 7:18 PM -
Thursday, October 1, 2020 7:20 PM
-
and as a FYI?
Well, if you do want say a delete button on a form?
Then you can display and show your own message, adn thus do what you want.
So, a delete button could prompt like this:
If MsgBox("Delete this record?", vbYesNoCancel, "delete?") = vbYes Then DoCmd.RunCommand acCmdDeleteRecord End If
So, you can write/have your own custom delete message. With set warnings false, then the above will not show any access UI prompts, but only your own custom message.
Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada
Thursday, October 1, 2020 7:26 PM