Ok, the following will use DAO, so if you don't have the reference set, you will need to
set it. To do so, open a code window (Alt+F11) and go to Tools|References. There should be
a check next to Microsoft DAO 3.6 Object Library. If you are using Access 97 or older,
this should already be set, but the version will be older than 3.6.
You will need to manually place an initial date in the table.
In the OnOpen event of the form you created:
Dim db As DAO.Database, strUser As String
Dim dteDate As Date
Set db = CurrentDb
strUser = CurrentUser
If strUser = "Admin" Then 'or whatever your login is
db.Execute "UPDATE Log SET Log.[Log In] = Date();", dbFailOnError
End If
dteDate = DLookup("[Log In]", "Log")
If DateDiff("d", dteDate, Date) > 30 Then 'pick your number of days here
db.Execute "DELETE * FROM TableName;"
'Do this for each table you want to delete data from
End If
Set db=Nothing
Application.SetOption "Auto Compact", True
Application.Quit
This is untested, but should be close enough to get you going.
--
Wayne Morgan
Microsoft Access MVP
"Zach" <(E-Mail Removed)> wrote in message news:02ef01c37a56$5144def0$(E-Mail Removed)...
> Ok I added the strUser to the on open to a form that I
> only use. I can read VB, but I dont know enough yet to
> write anything like this. Ive created a table called Log
> with a field called log in, using Date/Time, and input
> mask for short date.
> How Do I write the code to put my log in on open to this
> table and the code to compare it to a future date that
> keeps changing? Thank you for your help
> -Zach
|