Option Compare Database
Option Explicit
'**********************************************************************************************
'* WARNINING THIS FUNCTION WILL DISABLE THE SHIFT KEY BYPASS!!!!
'* Purpose: This Function is used to lock down the database so the "Shift" bypass function
'* won't work.
'*
'* Process: This function looks at the database's name to ensure it is the "Make MDE Version"
'* before implementing the setting changes.
'*
'* Therefore, you must make a copy of your database and name it "Make MDE Version" before
'* it will work. This ensure that you don't accidently
'* apply the setting changes on your development database.
'*
'* Last Updated: August 03, 1999 By: Chris Premo
'**********************************************************************************************
Sub SetBypassProperty()
Dim db As Database
Dim Prop As Property
Const conPropNotFound As Integer = 3270
Set db = CurrentDb()
Dim dbName As String
dbName = Right(db.Properties![Name], 20)
If dbName <> "Make MDE Version.mdb" Then
MsgBox "STOP!! DONT RUN THIS FROM THE DEVELOPMENT COPY!!", vbCritical
Else
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
Call DisableSpecialKeys
MsgBox "THE DATABASE HAS BEEN LOCKED! IF YOU FORGOT TO DO SOME CHANGES AND GET LOCKED OUT, JUST RE-COMPACT THE MASTER TO THIS COPY!", vbCritical
End If
End Sub
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
Function DisableSpecialKeys() As Boolean
On Error GoTo Err_DisableSpecialKeys
Dim db As Database
Dim Prop As Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowSpecialKeys") = False
Set db = Nothing
DisableSpecialKeys = True
Exit_DisableSpecialKeys:
Exit Function
Err_DisableSpecialKeys:
If Err = conPropNotFound Then
'If the property doesn't exist, create it
Set Prop = db.CreateProperty("AllowSpecialKeys", dbBoolean, True)
db.Properties.Append Prop
Resume Next
Else
MsgBox "Disable did not Work!!"
DisableSpecialKeys = False
Resume Exit_DisableSpecialKeys
End If
End Function