Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Shift Key at Startup 1

Status
Not open for further replies.

labprof

Technical User
Jan 26, 2006
49
US
I must be doing something wrong.
I am trying to disable the shift key at the start of my application so that the users cannot see, change, delete, etc... anything in my database.

I have read the faq181-143 that instructs you how to do this. I have typed both sets of codes in "twice".

I have an opening menu form that opens when the database is started. I've tried putting the code in On Open, also
On Load,.... I've even made buttons with the code set on click... I just can't get this to work.

When I initiate the on click code ~ I always get a screen that says Private Sub On Click ()
Although the code calls for typing in Public Sub....

Can someone help me understand what I am doing wrong?

Your help is appreciated.

Labprof
 
I have my Shift Key Disabled on Startup. I have a button on my Main Switchboard that allows you to enter a password to Enable the shift key. I will try to walk you through what I have done.

First, Make a COMPLETE backup of your database. Then try this:


Paste this in a new Module and name it ByPass


Option Explicit

Public Function SetProperties(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer

On Error GoTo Err_SetProperties

Dim db As DAO.Database, prp As DAO.Property

Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing

Exit_SetProperties:
Exit Function

Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function



Then create a NEW command button on your swicthboard. I named mine ByPass.

Type bDisableBypassKey in the Name line.

Then paste the following in the OnClick Event.



On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
If strInput = "YourPassword" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup options the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub



Replace YourPassword above with whatever password you want.


I believe that's it. Try this and you should be able to type in your password and ReEnable the Shift ByPass for your needs. Then Disable it for everyone else.

Good Luck.


Thomas Bailey
a/k/a TomCat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top