Delete Query Could not delete from specified tables

F

fred

I'm trying to run a delete query.

I'm running the following SQL code:

DELETE tblPeople.*, tblPeople.DateCreated, tblCases.CaseID
FROM tblPeople LEFT JOIN tblCases ON tblPeople.PersonID =
tblCases.PersonID
WHERE (((tblPeople.DateCreated)<#6/1/2004#) AND ((tblCases.CaseID) Is
Null));

Access returns the error "Could not delete from specified tables"

tblpeople has a relationship with tblcases.
 
D

Douglas J. Steele

You can't delete from two different tables in the same query.

Try removing

, tblPeople.DateCreated, tblCases.CaseID

from the query.
 
K

Ken Sheridan

I suspect you'll need to use a subquery for this:

DELETE *
FROM tblPeople
WHERE DateCreated < #6/1/2004#
AND NOT EXISTS
(SELECT *
FROM tblCases
WHERE tblCases.PersonID = tblPeople.PersonID);
 

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