Exit Database if not Trusted (1 Viewer)

arvdot

Registered User.
Local time
Today, 10:08
Joined
Mar 13, 2009
Messages
21
Hi, I have set up an autoexec macro as so:

Not [CurrentProject].[IsTrusted] MsgBox "Please add this database to a trusted folder"
... CloseDatabase

Now, I designed this code so that no one can avoid the security features I have on sensitive data, as when the database is actually trusted I have implemented a full lock down mode. The only problem I am having is that I can still break the macro with the CTRL-Break sequence. Is there any way to disable the CTRL-Break? Or to close the database if someone does to it? Any insight would be greatly appreciated. Thanks!

Edit: Use Access Special Keys is already disabled and it doesn't do the trick.
 

arvdot

Registered User.
Local time
Today, 10:08
Joined
Mar 13, 2009
Messages
21
Okay so I was a little bit dumb when I was thinking about this problem. I forgot that Access will automatically close an accde file that a user chooses not to allow code from. So I made my file accde. But also, I figured how to get rid of the control break sequence. Except the funny thing is, I can't get it back! I'm pretty sure you have to reset it on close to restore the functionality to your database. But here's the line that did it for me

ChangeProperty "EnableCancelKey", 1, False

Function ChangeProperty(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
 

Users who are viewing this thread

Top Bottom