My own message when delete can´t occur due to relationships

  • Thread starter Vasco Fernandes
  • Start date
V

Vasco Fernandes

I have the following problem:

I would like to make a personalized msgbox (in my own mother language, that
differs from the access version i have installed), when a parent record (in a
one to many relationship without cascade delete) tries to be deleted, i.e.:

- If a parent record has no childs, i want it to be deleted without warning;
- if it can´t be deleted due to having child records, i would like to have
my own msgbox, instead default one.

I wasn´t successful preventing the default message with docmd.setwarnings
false, and worked around the 3 delete associated events, but no success.

Any suggestions? Thanks in advance.
 
E

Evi

You could code it into your form. Build a Sql string for your delete but
always check on a copy of your db first until you are sure it is only
deleting what you want it to

MySql = "DELETE TblItem.* FROM TblItem WHERE (put your criterial here);"


If MsgBox ("YourMessage",vbYesNo) = vbYes THEN
CurrentDb.Excecute MySql, dbFailOnError
End If

Execute kills silently and without warning!

Evi



to delete stuff
 
D

Dale Fye

You could approach this one of two ways.

1. You could try to execute the delete, then trap for the error

or

2. You could test to see whether a child exist before trying the delete.
If the child deletes, display a message and ask whether they want to delete
the children as well as the parent record. If so, delete from the child
table first, then from the parent table.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 

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