delete query not working (1 Viewer)

cpampas

Registered User.
Local time
Today, 14:56
Joined
Jul 23, 2012
Messages
218
Hi,

I want to run a delete query like this :

Code:
DELETE tblApostasTemp.*, tblDatasJogos.data
FROM tblApostasTemp INNER JOIN tblDatasJogos ON tblApostasTemp.jogo = tblDatasJogos.jogo
WHERE (((tblDatasJogos.data)<Now()));

None of the joining fields are primary keys in each table: tblApostasTemp.jogo , and the field tblDatasJogos.jogo
If I run que query as dataSheet view, all the data that I want to delete, list correctly, but if I run as a delete query , an error pops up "not posible to eliminate from the specified tables".

Any thoughts ?
 

isladogs

MVP / VIP
Local time
Today, 22:56
Joined
Jan 14, 2017
Messages
18,212
When you look at it in datasheet view, is the query read only?
To change that you must set Unique Records =Yes on the property sheet.
In SQL, that is DELETE DISTINCTROW …..
 

cpampas

Registered User.
Local time
Today, 14:56
Joined
Jul 23, 2012
Messages
218
the query is not read only, so I did what you suggested and ...
it works great, thanks a lot !!!
 

isladogs

MVP / VIP
Local time
Today, 22:56
Joined
Jan 14, 2017
Messages
18,212
Excellent. Access will always give that error if there is any ambiguity about which records should be deleted.
That often the case where you have 2 tables in your delete query design
Recommend using DELETE DISTINCTROW whenever you have more than one table
 

Users who are viewing this thread

Top Bottom