delete - warning message

mattwebb

New member
Local time
Today, 22:25
Joined
Jan 31, 2004
Messages
7
Hi,

I have a standard delete button on a data input form. I have cascading delete enabled one some relationships but not on all. In order to display my own custom delete message i have used..

DoCmd.SetWarnings False

...so as not to display the access warning messages when deleting records. This is fine when i am deleting a record that is related to tables that i am allowing deletes to cascade to. However when i try to delete a record that has related data in a table which i dont want to cascade deletes to i get the following message...

"The record cannot be delete because the table 'x' includes related records"

...Ideally what I would like to do is capture the error here and display a custom message to the user. However when i use MsgBox DataErr no error code is present. It seems that this message is neither a warning or an error????????!!!!

Any help with this would be much appreciated.
 
Acces won't let you delete the record because the record is part of a relationship where there is a related record in another table.

I don't think this is customisable. Access won't let you do this!

Andy
 
What i have done is written a query that looks for any related records. I then write code
if dcount("*","queryname"....etc)>0 then
....action to be taken if theres is a related record
else
runsql(deletequery here)
end if

Might be clumsy but it works a treat

If you're good at the dcount paramaters you don't need to write a query just put the criteria in the dcount line!
 
hi, yes inded this works a treat....thanks very much for the tip
 

Users who are viewing this thread

Back
Top Bottom