HI all, Access 2003, Jet back end.
Rather than annoy my users in a particular app by having relationships
with enforced relational integrity refuse to delete a record with
related records, I'm using cascade delete. When I use a continuous form
and a record is deleted, Access provides a warning that there are
related records, do you want to continue (an aside - anyone know how to
trap that warning on the form on error event?). However, when I
construct SQL dynamically in VBA, say a string, strSql where strSql is
of the form "delete * from tbl_Whatever Where blah blah", and run:
DatabaseObject.Execute strSql, dbfailonerror
The warning about related records is not fired. In fact, it explicitly
says so in the help file that the warning will not be fired in this case.
So, what I've done in a couple of instances is simply make sure I know
what the relationships are with respect to the table in question and run
some DAO recordsets to see if there any related records and warn the
user when they press the button that fires the execute statement before
the button on click event gos ahead and constructs the delete statement.
This is sometimes rather arduous, especially in development where an app
may be frequently modified and more tables and more relationships added
later after launch or even throughout initial development and I'm
wondering if anyone has done anything that might be simpler.
Thanks in advance for any ideas.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto