Solved

Deleting Criteria

Posted on 2014-09-25
6
117 Views
Last Modified: 2014-09-25
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
0
Comment
Question by:ca1358
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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.
0
 

Author Comment

by:ca1358
Comment Utility
It did not work . Error "join Expression not supported "ON [CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]"
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:ca1358
Comment Utility
Including File with query "Delete_QRY
DeleteCriteria.mdb

When Hit Run Error is "Specify the table containing the records you want to delete.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
try this query, copy and paste

DELETE CMTS_Daily_Extract.*
FROM CMTS_Daily_Extract
Where exists(select DupsWithOnlyMINTime.TakenTime From DupsWithOnlyMINTime where DupsWithOnlyMINTime.CMTID=CMTS_Daily_Extract.CMTID And DupsWithOnlyMINTime.TakenTime=CMTS_Daily_Extract.TakenTime)
0
 

Author Closing Comment

by:ca1358
Comment Utility
Thank you!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now