Well yes, that's what I thought.
The designer, for some reason, created the first line as
delete a.*, b.type
and when I tried to run it I got the error message
"Cannot delete from the specified tables".
Thinking that it wanted to delete from the lookup table, which is a read-only link, I removed the b.type from the delete, but still get the same message.
I can delete from the target table via a query with no problem, so the difficulty must be with the lookup table.
But what ?
This is the acttual code:
DELETE P60_Payment_Detail.*
FROM P60_Payment_Detail INNER JOIN RO_EXII_V_PRODUCT ON [P60_Payment_Detail].[PolicyNumber]=[RO_EXII_V_PRODUCT].[SOURCE_SYSTEM_PRODUCT_REF]
WHERE ((([RO_EXII_V_PRODUCT].[PRODUCT_TYPE_ID]) Not In (220100,91000085)));
Hm - don't know, SQL has never been my strong side, perhaps try something like this:
[tt]DELETE a.*
FROM P60_Payment_Detail a
WHERE a.PolicyNumber =
(select
b.SOURCE_SYSTEM_PRODUCT_REF
from
RO_EXII_V_PRODUCT b
where
b.SOURCE_SYSTEM_PRODUCT_REF = a.PolicyNumber
and b.PRODUCT_TYPE_ID Not In (220100,91000085)
)[/tt]
Well, I've just tried something similar.
I created a select query for the records that I wanted to delete, then created a delete query with a straight join from p60_payment_detail to the new query.
Still get the same error.
I pasted your query in and ran it, but after watching the hourglass for quite a while, I gave up.
In Oracle, that would have worked a treat, but I'm not sure that Access is as sql-minded as that.
This is crazy.
I've seen examples of this done on the net !
I've now created a table of the items to be deleted, created a delete query with a join to it and I still get the error message.
There must be something very basic wrong here.
I created a new query and typed some sql in from scratch and it worked.
I went to design view and the new Access table with the keys of the records that I wanted to delete from p60_payment_detail didn't show.
It would appear that you only need to have the table you want to delete from showing in the design?
And this ?
DELETE FROM P60_Payment_Detail
WHERE PolicyNumber In (SELECT SOURCE_SYSTEM_PRODUCT_REF FROM RO_EXII_V_PRODUCT WHERE Not PRODUCT_TYPE_ID In (220100,91000085))
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.