Connecting Tech Pros Worldwide Help | Site Map

Automatic timed deletion of tables

Wilsoch
Guest
 
Posts: n/a
#1: Nov 13 '05
Non-programmer here again because my developer stinks. I'm desperately
seeking a solution to this issue:

I need something in the open event on my main form that will cause all
of the tables to delete after a set period of time (7 days).

The database will be run locally on individual user's machines. Also, I
have a date format issue because some of the users will have MM/DD/YY,
others will have DD/MM/YY on their systems.

Is it possible to do something like this? If you could put me on the
right track, I can keep searching through the myriad Access books I've
had to purchase.

pietlinden@hotmail.com
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Automatic timed deletion of tables


this one's a no-brainer.

Say you store the last date the delete was run in a custom property or
on a table... You can assign that value to a date variable and then run
all your deletes through code...

something like
dim tbl as string
for intCounter = 0 to CurrentDb.Tabledefs.Count-1
tbl=currentdb.tabledefs(intCounter).Name
If left$(tbl)<>"MSys" Then
CurrentDB.Execute "DELETE * FROM [" & tbl & "] WHERE
DateDiff("d",FieldInTable,Date)>7"), dbfailOnError
End If

note - this is all totally off the top of my head. And with a delete
query going on, test this first on a backup....

pietlinden@hotmail.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Automatic timed deletion of tables


oh, yeah...that word "timed" ... you could do this in the startup of
the app.... just call your function that does the deleting...

Wilsoch
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Automatic timed deletion of tables


Thanks for the info.

I thought the different date formats might cause an issue here. You
don't see that as an issue?

pietlinden@hotmail.com
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Automatic timed deletion of tables


The date formats shouldn't matter as long as their stored in a
consistent manner. As long as you store according to US format or
force the dates into US format, then it's fine. (Allen Browne etc -
the folks from down under can probably answer this better than I - as I
live in the US, so usually don't have to deal with it.)

Closed Thread