Re: Delete Query - Delete matching records from 2 tables - Access

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Many thanks for your help. Your last option worked fine.

Regards,
Chris

"John Spencer (MVP)" wrote:

YOu can only delete records from ONE table at a time.

STEP 1: BACKUP your data before attempting the following.
STEP 2: BACKUP your data before attempting the following.

Without a backup you cannot restore the data if this does not work the way you
expect.

To delete records from Daily Check the query might look like
DELETE
FROM [Daily Check]
WHERE policy in (SELECT Policy From Retention)

To delete records from Retention the query would look like
DELETE
FROM Retention
WHERE policy in (SELECT Policy From [Daily Check])

You *MIGHT* be able to get this to work. Note that only one table is
mentioned in the DELETE clause.
DELETE DISTINCTROW Retention.*
FROM [Daily Check] INNER JOIN Retention
ON [Daily Check].policy = Retention.POLICY;


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Chris Stammers wrote:
Hello,

I have a query to delete records that match from the 2 tables contained.
When I view the result of the query before running, it looks like it is going
to work however when I actually come to run it, I get the error 'Could Not
Delete From Specified Tables'. After reading the Help pages, I unchecked the
box 'Open Databases using record-level locking' from the Advanced Options tab
and this hasn't helped. Is it the case that I will need to close Access for
the tables to update before the query will run properly? Here is the SQL:
DELETE Retention.*, [Daily Check].policy, [Daily Check].[extracted on] AS
Expr1
FROM [Daily Check] INNER JOIN Retention ON [Daily Check].policy =
Retention.POLICY;

Many thanks.
Chris

.



Relevant Pages

  • Re: Delete Query - Delete matching records from 2 tables - Access 2000
    ... BACKUP your data before attempting the following. ... To delete records from Daily Check the query might look like ... WHERE policy in ... FROM INNER JOIN Retention ON.policy = ...
    (microsoft.public.access.queries)
  • Move row string to column
    ... (Policy DB1 Backup Policy for backup time 10:30 AM today ... Include C:\Program Files\Microsoft SQL Server\MSSQL$DBINSTANCE1\*, ... Policy DB1 Backup Policy for backup time 10:15 AM today ...
    (microsoft.public.windowsxp.general)
  • Re: Message of the day pop-up?
    ... Create a form based on a query against the table that selects ... the record where the date in LastShown matches today's date ... Dateand ProcedureID = the next randomId generated by your randomizing ... show the newly selected policy. ...
    (microsoft.public.access.queries)
  • Re: Message of the day pop-up?
    ... "John Spencer" wrote: ... Create a form based on a query against the table that selects ... Dateand ProcedureID = the next randomId generated by your randomizing ... show the newly selected policy. ...
    (microsoft.public.access.queries)
  • Re: Need all fields from both tables
    ... A single query cannot do this. ... Number of fields in a recordset 255 ... The tables consist of a policy number and the ... Please reply to the newsgroup. ...
    (microsoft.public.access.queries)