How do u automatically delete records after a set peroid of time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi could sum1 plz tell me how to automatically delete records after three
yrs. if sum1 could tell me the automated routine how to do this?! thx
 
fishkabob said:
Hi could sum1 plz tell me how to automatically delete records after
three yrs. if sum1 could tell me the automated routine how to do
this?! thx

Does the database currently track the date the record was created, or
last modified or last read or whatever bases for the beginning of your time
period might be? Access does not do this automatically, it has to be
programmed, so unless it is already there Access will have no way of knowing
what is that old.
 
Fishkabob,

Presumably you have a field in the table in question that identifies
when the record was first entered? If so, you can make a Delete Query,
with this in the Criteria of the date field....
<DateAdd("yyyy",-3,Date())

To make it automatic, you could use a macro or VBA procedure to run this
Delete Query. This could be done, for example, on the Open event of a
form which always opens whenever the database is opened, or some other
appropriate event. In a macro, you would use an OpenQuery action,
preceded by a SetWarnings/No action to suppress the display of the
action query confirmation prompts. In a VBA procedure, you could do
like this...
CurrentDb.Execute "DELETE * FROM YourTable WHERE YourDate
<DateAdd('yyyy',-3,Date())"
 

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

Back
Top