Append and Delete Queries

  • Thread starter Walter Steadman
  • Start date
W

Walter Steadman

I have built an Append Query that will copy records older than 180 days to a
new table called Archive.
I have also built a query that deletes the same records from the current
table.

Is there a way to do this all at once or do I have to run both queries. I
am using it to Archive older records into a separate table.

TIA

Wally Steadman
US Army in Iraq
 
R

Rick Brandt

Walter said:
I have built an Append Query that will copy records older than 180
days to a new table called Archive.
I have also built a query that deletes the same records from the
current table.

Is there a way to do this all at once or do I have to run both
queries. I am using it to Archive older records into a separate
table.

It would ne much better to simply add a Yes/No field that marks records as
"inactive" or "archived" and then filter those rows out of your normal
processes. Archiving seldom accomplishes much of anything and in the few cases
where it makes sense it would be to make "before" copies of changed records.

Another case where it can be justified is if you need to move the data to
another *file* to prevent your primary file from exceeding the size limit for
Access. Moving it to another table within the same file has little benefit that
I can see.

Another advantage of using a flag field is that on those occasions where you
want to query across active and inactive records it is easy because they are all
still in one table.

If I were going to do the "move" thing I would execute both queries from code
within a transaction. You don't want the copy query to fail and then still
execute the delete query as now the records are gone.

dbEngine.BeginTransaction
CurrentDB.Execute "AppendQueryName", dbFailOnError
CurrentDB.Execute "DeleteQueryName, dbFailOnError
dbEngine.CommitTransaction

This would be wrapped in an error handler with the error trap issuing a Rollback
on the transaction.
 
W

Walter Steadman

So would I do an OnOpen event so that if the table was opened, and dates
fell prior to a certain date they would become inactive thus changing the
YesNo field to No. Guess I would default them all to yes. That is a great
idea and I like your thought on not having them in two tables.

I am on Yahoo Messenger as Walter_Steadman if anyone would care to chat
about this Database stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top