I want to eliminate users from going to explorer and Hitting Shift to enter the database. I read Faq181-143 and that doesn't eliminate the access through explorer. Am I just calling it wrong or is there another way.
The next best thing is to create an .mde file for the users. They will still be able to shift into the mde file, but they will not be able to get into the design view of any forms or reports.
Copy the following code into a module and run the code. When you close your database and open it the next time it will no allow the shift key to operate on any access special keys. To set the property back change the allow bypass keys condition to = true
Option Compare Database
Option Explicit
Function PreventBypass() As Boolean
'Dim prp As Property
I used a different approach. I picked it up from here (sorry, I don't remember who posted it) and added a few modifications of my own.
I have a single record/single field table called tblByPass; the field is called ByPass and is a Yes/No type.
I put a command button (cmdSet) on one of the menu forms and set it's visible property to No. When I click this it toggles the Yes/No state of the field ByPass and depending on the state of ByPass calls either the EnableKey or DisableKey procedure.
This is the code for cmdSet:
Private Sub cmdSet_Click()
Dim dbTemp As Database
Dim rsTemp As Recordset
Set dbTemp = CurrentDb
Set rsTemp = dbTemp.OpenRecordset("tblByPass"
If rsTemp.Fields(0) = True Then
rsTemp.Edit
rsTemp.Fields(0) = False
EnableKey
Else
rsTemp.Edit
rsTemp.Fields(0) = True
DisableKey
End If
rsTemp.Update
rsTemp.Close
End Sub
And this is the code for the two subs:
Public Sub EnableKey()
Dim db As Database
Dim prp As Property
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, True)
db.Properties.Append prp
End Sub
Public Sub DisableKey()
Dim db As Database
Dim prp As Property
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prp
End Sub
It is a tad bit clunky but it does the trick. If the bypass key has been disabled, all you need to do is click on the "hidden" button to re-enable it, exit the database and then open it again using the shift key. When you are done making changes, simply click on the button again to disable. If you don't let your users in on the secret it's almost fool proof.
Larry De Laruelle
larry1de@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.