Del query using criteria from another table

captnk

Registered User.
Local time
Today, 08:34
Joined
Dec 12, 2001
Messages
148
I have a table to which I append data,(as a quick restore feature,to save redoing calcs from the main table).

However if I alter the main table I may want to resave the changes,but an append query doesnt replace existing data.

SO i need to set up a Delete query that will delete data from the append table,that fits a criteria from the main table,(which I call
Code:
,comprising [date&location]
Whilst a select query will find the relevant data,with the main,and append tables in the query,It will not let me run it as aDel query and keeps asking for the table to be deleted to be specified.
However I have tried heaps combinations and nothing works.

Any suggestions as to how I can set up the del query using the "code" field from the main table to delete the same code in the append table please

Captnk
 
Perhaps: create a select query that identifies the relevant records on the main table. Create a delete query based on the history table and the first query.

Or perhaps: make the second query an update query so you don't have to delete and recreate.

Or perhaps: Delete the whole of the history table and recreate it afresh.

All depends on what exactly you want to do
 
Tks Neil.
Probably yr first suggestion is best.
I dont think I made it totally clear.
The main table has only 1 set of "code" reference data.
The append table has multiple code data,ie a copy of evrything that has been lookd at in the main table.
So deletes from append are only partial,when the main has been changed in some way and needs to be saved
However the difficulty with that is I am having a problem doing a delete query where it refers to a criteria in another table/query.It keeps asking me to define the Delete table.....and thats the part I cant get past
 
Try this query (type in the SQL View of a new query, using the correct table names, field names, and criteria):-

DELETE *
FROM [append table]
WHERE
Code:
 in (Select [Code] from [main table] where [criteria field]=criteria)
 
Jon K
Many Thanks.
That works brilliantly

Regards
Captnk
 

Users who are viewing this thread

Back
Top Bottom