Could not delete from specific table (1 Viewer)

willy292

Registered User.
Local time
Today, 14:58
Joined
Jul 10, 2013
Messages
11
Query4 is the result from left joining of Query3 and Query1
and I would like to delete some of the null data in query 4

while I execute the following code
DELETE DISTINCTROW Query4.*, [working hour] AS Expr1
FROM Query4
WHERE (((query4.[working hour])=0));

I get the warning of "Could not delete from specific table"

can anyone help, thanks.
 

willy292

Registered User.
Local time
Today, 14:58
Joined
Jul 10, 2013
Messages
11
if my query has a GROUP BY clause and also union what can I do if I really want to return the relevant row only
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:58
Joined
Aug 30, 2003
Messages
36,137
I don't know your data, but either one of those makes the query read only. Perhaps you can get a key value from that query that you can use in a separate delete query.
 

Cronk

Registered User.
Local time
Tomorrow, 07:58
Joined
Jul 4, 2013
Messages
2,774
Will
You can't delete from an outer join query.

Make Query4 a select query, then have the delete query
Delete TableX.* FROM TableX where TableX.ID in (Select ID from Query4)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:58
Joined
Feb 19, 2002
Messages
43,550
@Cronk, Yes, you can delete from an outer join. BUT, when multiple tables are included in the query, rows are only deleted from the LOWEST level table. So in a query that selects orders and order details, you can delete detail records but you CANNOT delete orders and you won't get an error message.

@Willy and PBaldy, No, you cannot delete from Union or Totals or Crosstab or any other type that loses the identity of individual records.

Willy, if your criteria for deletion is coming from a child table, you may be able to accomplish what you need by using a sub query. The outer query will check for presence in the sub query but will not select any columns from it. If you can't get the sub query to work, you can turn your current query into a make-table query, Update the table to select the PK. Then create a new delete query that joins to the make table. This is only a viable solution if this is a one-time action. If you will need to do it on a regular basis, I would create a VBA procedure that identifies the records you want to delete and then deletes them if you can't get the sub query to work.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:58
Joined
Aug 30, 2003
Messages
36,137
@Willy and PBaldy, No, you cannot delete from Union or Totals or Crosstab or any other type that loses the identity of individual records.

Did I imply otherwise? I said "either one of those makes the query read only".
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:58
Joined
Aug 30, 2003
Messages
36,137
No problem Pat; just wanted to make sure I hadn't screwed up...again.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:58
Joined
Feb 19, 2002
Messages
43,550
You're not one of the people who screws up. Your advice is sound and accurate.
 

Users who are viewing this thread

Top Bottom