?
Solved

Deleting Criteria

Posted on 2014-09-25
6
Medium Priority
?
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 38

Expert Comment

by:PatHartman
ID: 40344576
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
ID: 40344595
It did not work . Error "join Expression not supported "ON [CMTS_Daily_Extract]![TakenTime]=[DupsWithOnlyMINTime]![TakenTime]"
0
 
LVL 38

Expert Comment

by:PatHartman
ID: 40344628
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:ca1358
ID: 40344650
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40344740
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
ID: 40344752
Thank you!!
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

743 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