Delete file or all table after certain period of time

maabbas

Registered User.
Local time
Today, 10:45
Joined
Feb 15, 2012
Messages
69
Is there any VBA code which delete all tabel, or run delete query after certain period of time?

any help will be greatly appreiciated
 
Welcome to the forum.

The code discussed in this thread should provide you with the answer to the first part of your question.

You could test the Current Date against your Dead Line date in the On Load event of your Welcome form. Something along the lines of;
Code:
If Date() > 01/01/2099 Then
     [COLOR="Green"]'Run your self destruct code here[/COLOR]
End If
This will run your Self Destruct code the first time the DB is opened after 01/01/2099 (you would of course replace that date with your own deadline date)

You may also want to consider Disabling the Shift Key By Pass, to prevent savy users circumventing your code
 
I am new in Acces and do not know much about VBA, will you please explain what is Load event and where i will test the above code?
 
I am new in Acces and do not know much about VBA, will you please explain what is Load event and where i will test the above code?

Which prompts me to ask a question, that perhaps should have been asked earlier. Why exactly do you wish to delete all tables in your DB after a certain date :confused:
 
Which prompts me to ask a question, that perhaps should have been asked earlier. Why exactly do you wish to delete all tables in your DB after a certain date :confused:

Yes Sir, I want to use this database till certain period e.g. 03/15/12, and after this date, when someone try to open the file, its delete the file or corrupt the data.

I used a following VBA code for excel, and tested it works for excel I want same kind of code which works for Access.

Please remeber following code only works for Excel

Private Sub Workbook_Open()
Dim XDate As Date
XDate = #12/31/2012# ' Assign a date.
If Date >= XDate Then
MsgBox "Your File has Expired"
Me.ChangeFileAccess xlReadOnly
Kill Me.FullName
Me.Close False
End If
Reset
End Sub
 

Users who are viewing this thread

Back
Top Bottom