Link to home
Start Free TrialLog in
Avatar of ca1358
ca1358

asked on

Deleting Criteria

I included a Sample Database.
 Problem is the Delete query.  When I view it gives the right information.
But when I hit Run  it states “Specify the table containing the records you want to delete.  Everything  I TRIED AS NOT WORKED.
The Records need to delete out table ‘CMTS_Daily_Extract and the MinTime Taken only leaving the Max Time.

This is the criteria :WHERE (([CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]));

SQL View: DELETE CMTS_Daily_Extract.CMTID, CMTS_Daily_Extract.TakenTime
FROM CMTS_Daily_Extract, DupsWithOnlyMINTime
WHERE (([CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]));

I greatly appreciate any help!


DeleteCriteria.mdb
Avatar of PatHartman
PatHartman
Flag of United States of America image

The query doesn't include a specific join so it is creating a Cartesian Product which is NOT updateable.

Try
SQL View: DELETE CMTS_Daily_Extract.*
 FROM CMTS_Daily_Extract Inner Join DupsWithOnlyMINTime
 ON (([CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]));

If that doesn't work, it is because of the aggregation in the Dups query.  A subselect might work so you can try that.  If nothing else works to make the query updateable, then you need to create a temp table to hold the dups and join to that instead of to the query.  Most of the time, you should avoid temp tables like the plague.  Use them only if you start with a large number of rows and through lots of manipulation end up with a few rows and you need to use the result set more than once OR as in this case if your action query must join to aggregated data and that is making the query non-updateable.
Avatar of ca1358
ca1358

ASKER

It did not work . Error "join Expression not supported "ON [CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]"
Rather than trying to debug the syntax with our eyes, build the query using the QBE.  

Add both tables.
Draw the join line.
Change the query type to Delete.
Avatar of ca1358

ASKER

Including File with query "Delete_QRY
DeleteCriteria.mdb

When Hit Run Error is "Specify the table containing the records you want to delete.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ca1358

ASKER

Thank you!!