Script to disable Shify Bypass

E

eric

I need to disable the ShiftBypassKey for a database. I
have the sample code from the Microsoft Access Security
FAQ, but have little knowledge of Visual Basic. If
someone could please help me by modifying the follownig
string so that I can simply copy & paste, I would greatly
appreciate it. Thanks in advance.


I have created a new administrator user. "Admin" is
simply a user with no advanced security rights.


MS Access 97
Database Name: Profiler.mdb
Database Location: c:\data\databases\
Workgroup: Unsure where to find this


Here is the code from the FAQs:

Function faq_DisableShiftKeyBypass(strDBName as String,
fAllow as Boolean) As Boolean

On Error GoTo errDisableShift

Dim ws As Workspace
Dim db As DATABASE
Dim prop As Property
Const conPropNotFound = 3270

Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(strDBName)

db.Properties("AllowByPassKey") = Not fAllow
faq_DisableShiftKeyBypass = fAllow
exitDisableShift:
Exit Function

errDisableShift:
'The AllowBypassKey property is a user-defined
' property of the database that must be created
' before it can be set. This error code will execute
' the first time this function is run in a database.

If Err = conPropNotFound Then
' You must set the fourth DDL parameter to True
' to ensure that only administrators
' can modify it later. If it was created wrongly,
then
' delete it and re-create it correctly.
Set prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, False, True)
db.Properties.Append prop
Resume
Else
MsgBox "Function DisableShiftKeyBypass did not
complete successfully."
Faq_DisableShiftKeyBypass = False
GoTo exitDisableShift
End If
End Function
 
J

Joel Wiseheart

I use the following in all of my databases. It contains 3
functions:

1) Append the "AllowBypassKey" property to the current
database, and set it to false.

2) function that can be assigned to an OnClick event of a
button, or a macro, to toggle the "AllowBypassKey"
property, in case I want to turn the functionality back
on for developing.

3) A "shift lock indicator" function, that I can display
on a form in a control called LockIndicator (I put it on
the Siwtchboard form), so that I can tell at a glance
what the current "locked status" is.

HTH
Joel
*******************************************************

Option Compare Database
Option Explicit

Public Sub CreateProperty()
Dim db As DAO.Database
Dim prop As DAO.Property
On Error GoTo Fehler:
Set db = CurrentDb
Set prop = db.CreateProperty
With prop
.Name = "AllowByPassKey"
.Type = dbBoolean
.Value = False
End With
db.Properties.Append prop
Exit Sub
Fehler:
Select Case Err.Number
Case 3367
MsgBox "Property exists already!"
Case Else
MsgBox Err.Number & vbCr & Err.Description
End Select
End Sub


Function ShiftAnAus()
Dim db As DAO.Database
Set db = CurrentDb
db.Properties("AllowByPassKey") = Not db.Properties
("AllowByPassKey")
Select Case db.Properties("AllowByPassKey")
Case True
DoCmd.OpenForm "Switchboard", acNormal, , ,
acFormReadOnly
MsgBox "Database is open"
Forms!Switchboard.LockIndicator = False
Case Else
DoCmd.OpenForm "Switchboard", acNormal, , ,
acFormReadOnly
MsgBox "database is locked"
Forms!Switchboard.LockIndicator = True
End Select
End Function

Function ShiftLockStartup()
Dim db As DAO.Database
Set db = CurrentDb
Forms!Switchboard.LockIndicator = Not db.Properties
("AllowByPassKey")
Set db = Nothing
End Function

**********************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top