[AccessD] Delete Query with a join

David McAfee davidmcafee at gmail.com
Thu Aug 28 12:16:19 CDT 2014


It's been a while since I've used Access (especially the GUI Query tools).

In MSSQL, I can delete a table as such:

DELETE [rpt_DMHClaim 14]
FROM [rpt_DMHClaim 14]
INNER JOIN [qry 01a rpt_DMHClaim 14 Dupes to be deleted]
ON [rpt_DMHClaim 14].ClaimNumber = [qry 01a rpt_DMHClaim 14 Dupes to be
deleted].ClaimNumber AND [rpt_DMHClaim 14].EOB_ID = [qry 01a rpt_DMHClaim
14 Dupes to be deleted].MaxOfEOB_ID



But Access doesn't like that.I thought this would work in Access:

DELETE DISTINCTROW [rpt_DMHClaim 14].*
FROM [rpt_DMHClaim 14]
INNER JOIN [qry 01a rpt_DMHClaim 14 Dupes to be deleted]
ON [rpt_DMHClaim 14].ClaimNumber = [qry 01a rpt_DMHClaim 14 Dupes to be
deleted].ClaimNumber AND [rpt_DMHClaim 14].EOB_ID = [qry 01a rpt_DMHClaim
14 Dupes to be deleted].MaxOfEOB_ID



But I get a message that Access cannot delete from Specified tables

This works, but to me shouldn't be correct:

DELETE [rpt_DMHClaim 14].ClaimNumber, [rpt_DMHClaim 14].EOB_ID
FROM [rpt_DMHClaim 14]
WHERE ((([rpt_DMHClaim 14].ClaimNumber) In (SELECT [ClaimNumber] FROM [qry
01a rpt_DMHClaim 14 Dupes to be deleted] )) AND (([rpt_DMHClaim 14].EOB_ID)
In (SELECT [MaxOfEOB_ID] FROM [qry 01a rpt_DMHClaim 14 Dupes to be deleted]
)));



Does anyone see what mistake I am making?

TIA

D


More information about the AccessD mailing list