Delete Query - Delete records in Table 1 using parameters from Tab

G

Guest

I'm trying to delete records in Table 1 (tbl_Pending Rebate Approval), after
they have been transferred to Table 2 (tbl_Rebate Approvals). So I created a
query that says:

DELETE [tbl_Pending Rebate Approval].*, [tbl_Rebate Approvals].PENDINGID
FROM [tbl_Pending Rebate Approval] INNER JOIN [tbl_Rebate Approvals] ON
[tbl_Pending Rebate Approval].PENDING_ID = [tbl_Rebate Approvals].PENDINGID;

However, I keep getting an error of: Couldn't Delete From Specified Table.

I want this query to remove the records in Table 1 (tbl_Pending Rebate
Approval) if it exists in Table 2 (tbl_Rebate Approvals).
 
J

John Spencer (MVP)

First, you should only have a reference to ONE table in the DELETE clause.

DELETE [tbl_Pending Rebate Approval].*
FROM [tbl_Pending Rebate Approval] INNER JOIN [tbl_Rebate Approvals] ON
[tbl_Pending Rebate Approval].PENDING_ID = [tbl_Rebate Approvals].PENDINGID;

IF that doesn't work then try

DELETE [tbl_Pending Rebate Approval].*
FROM [tbl_Pending Rebate Approval]
WHERE [tbl_Pending Rebate Approval].PENDING_ID IN
(SELECT [tbl_Rebate Approvals].PENDINGID
FROM [tbl_Rebate Approvals])

IF that fails then try adding DistinctRow to the Delete clause.
 
G

Guest

John,

The second option worked like a charm. Thank you very much for all of your
help.

Have a great day,
Jen

John Spencer (MVP) said:
First, you should only have a reference to ONE table in the DELETE clause.

DELETE [tbl_Pending Rebate Approval].*
FROM [tbl_Pending Rebate Approval] INNER JOIN [tbl_Rebate Approvals] ON
[tbl_Pending Rebate Approval].PENDING_ID = [tbl_Rebate Approvals].PENDINGID;

IF that doesn't work then try

DELETE [tbl_Pending Rebate Approval].*
FROM [tbl_Pending Rebate Approval]
WHERE [tbl_Pending Rebate Approval].PENDING_ID IN
(SELECT [tbl_Rebate Approvals].PENDINGID
FROM [tbl_Rebate Approvals])

IF that fails then try adding DistinctRow to the Delete clause.
Jen said:
I'm trying to delete records in Table 1 (tbl_Pending Rebate Approval), after
they have been transferred to Table 2 (tbl_Rebate Approvals). So I created a
query that says:

DELETE [tbl_Pending Rebate Approval].*, [tbl_Rebate Approvals].PENDINGID
FROM [tbl_Pending Rebate Approval] INNER JOIN [tbl_Rebate Approvals] ON
[tbl_Pending Rebate Approval].PENDING_ID = [tbl_Rebate Approvals].PENDINGID;

However, I keep getting an error of: Couldn't Delete From Specified Table.

I want this query to remove the records in Table 1 (tbl_Pending Rebate
Approval) if it exists in Table 2 (tbl_Rebate Approvals).
 

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