Is it possible? Yes. But Access isn't really known for its robust security and a determined user could probably get in anyway. Here is my stab at it:
- Option Compare Database
-
Option Explicit
-
-
Function CheckDate()
-
If Now() > #3/31/2010# Then
-
MsgBox "Validity date has expired."
-
DoCmd.Quit acQuitSaveNone
-
End If
-
End Function
-
-
Function SetBypassKey(BypassValue As Boolean)
-
Const conPropNotFound As Integer = 3270
-
On Error GoTo createProp
-
CurrentDb.Properties("AllowByPassKey") = BypassValue
-
Exit Function
-
-
createProp:
-
If Err = conPropNotFound Then
-
Dim Bypass As Property
-
Set Bypass = CurrentDb.CreateProperty("AllowByPassKey", dbBoolean, False)
-
CurrentDb.Properties.Append Bypass
-
Resume Next
-
End If
-
End Function
1. First, make a copy of your database to work with. It would be unwise to block yourself out of your own work.
2. Create a macro named autoexec. In it, put the RunCode action and put CheckDate() in the arguments. If your database is code heavy, calling it at the beginning of important pieces of code will make it harder to get around as well.
3. From the immediate window, type SetBypassKey False. You'll only have to do this once for the database. This makes it so you can't hold down Shift while opening the database to skip the autoexec macro.
4. Convert the database to .accde / .mde so no one can see or modify your code.
That takes care of all the ways in I can think of, but like I said... I make no guarantees as to this being ironclad.