View Single Post
  #1  
Old February 5th, 2006, 04:15 AM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Delete Query Does Not


I have a database that won't let me delete records using a Delete Query.

I have an Access 2003 database that has several tables in it that are all
related to a client table and have referential integraty and the cascade
delete enabled.

I wish to delete all clients that have not been seen for two years or more.
And yes, I really want to delete them.

A "meal" table contains the last visit date. See relationships...

The idea is to find all clients who have not been seen in two or more years
and delete them.
The data sheet view shows that the correct clients are selected. However,
when I try to run the delete query it says it cannot delete the records. The
"client" table is the table to which all other tables are related to.

I don't care if I loose all the data for a client. If the client has not
been in in two years a new record would have to be created anyway.

The SQL generated is:

DELETE client.*, client.MasterID, meals.LastVisit, client.f_name,
client.l_name
FROM client INNER JOIN meals ON client.MasterID = meals.MasterID
WHERE (((meals.LastVisit)Date()-730));

The error message says: "Cannot delete from table".

Does anyone have an idea as to why this does not work and what might be done
to make it work??

Thanks!