Solved

Deleting Criteria

Posted on 2014-09-25
6
119 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 35

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 35

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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 500 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Field Properties in the DB Vs Bound Control on the form 9 33
Combobox row source 2 21
Switch 5 18
Display <> "Yes" records 10 10
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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