Shift key (1 Viewer)

Rob.Mills

Registered User.
Local time
Today, 17:07
Joined
Aug 29, 2002
Messages
871
Does anyone know how to change the combination to something other than the shift key to bypass the startup?
 

Hellfire

Registered User.
Local time
Today, 22:07
Joined
Jul 23, 2002
Messages
57
Hi,

I have a small db that will allow you to change the accesability of any access db. Even if you have taken away the shift-key access, you can still enable it again with this.

Let me know, and I will send it to you.
 

adi32

Registered User.
Local time
Today, 22:07
Joined
Dec 6, 2000
Messages
82
do you know if it is possible to lock permanently the shift key even if the user has this program?
 

Rob.Mills

Registered User.
Local time
Today, 17:07
Joined
Aug 29, 2002
Messages
871
This system works great. Thanks!!

Out of curiousity, is it possible to instead of disabling the process but change it. In other words use a different combination of keys to do the same thing. Sort of like a bypass password?
 

llkhoutx

Registered User.
Local time
Today, 16:07
Joined
Feb 26, 2001
Messages
4,018
I was not able to jump directly to foregoing the link. I had to register for the Tek-Tips Form, sorry Jon (you're still the best for getting questions answered promptly), and then search the various Access topics, but I found it.

It's in the "Microsoft: Access Other Topics FAQ Index", "FAQs" tab, at topic 7.x.
 

ghudson

Registered User.
Local time
Today, 17:07
Joined
Jun 8, 2002
Messages
6,195
The below function and command button code will allow you to use a password
protected input box to determine if the Shift key can be disabled or not.

You might have to set your "References" to DAO 3.6. When you are viewing
the module, click the Tools menu >>> References >>> and Browse for Microsoft
DAO 3.6 >>> Select "Files of type: Executable Files (*.exe; *.dll)"
My DLL was located @ C:\Program Files\Common Files\Microsoft Shared\DAO.

Copy this function into a new public module.
Code:
Public Function SetProperties(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
    
    'Dim db As Database, prp As Property
    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 "Runtime Error # " & Err.Number & vbCrLf & vbLf & Err.Description
        Resume Exit_SetProperties
    End If
    
End Function
Assign this to the OnClick event of a command (transparent?) button named "bDisableBypassKey".
Change the "TypeYourPasswordHere" default password.
This sub ensures the user is the programmer needing to disable the Bypass Key.
You can not format an Input Box!
Code:
Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
    
    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 = "TypeYourPasswordHere" 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 "Runtime Error # " & Err.Number & vbCrLf & vbLf & Err.Description
    Resume Exit_bDisableBypassKey_Click
    
End Sub
HTH
 
Last edited:

AdamO

Registered User.
Local time
Today, 22:07
Joined
Jun 26, 2002
Messages
40
ghudson,

I like the your solution you posted & have tried it in an Access 2000 database.

What I get is the dialogue asking for the password, which when entering disables the shift key when you next open the database. Great. This remains until you disable. To disable I presume you have to enter an incorrect password, which will disable.

I would like to make sure I have covered everything. I have created a module with your code and entered the code for the click event on a form command button. When opening the module'Microsoft DAO 3.6 Object Library' is one of the items ticked. It is in the same directory as the one you mentioned. When I browse the type libraries are *.olb, *.tlb & *.dll. Am I supposed to open something here?. Forgive me, this is relatively new to me, I am not sure what you mean by 'dimension your code, i.e.... Dim db As DAO.Database, prp As DAO.Property'.

Apologies if I am worrying unduly. If my interpretation in para 2 is correct on how it should work - it does.

Thanks.
 

Rob.Mills

Registered User.
Local time
Today, 17:07
Joined
Aug 29, 2002
Messages
871
ghudson,

I've copied this code into my database and adjusted accordingly. When I run it I get a 'Type Mismatch' Error. When I run debug (disabled On Error so I could do this) it highlights this part of the SetProperties function:

Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)


Any idea why that might be happening?
 

ghudson

Registered User.
Local time
Today, 17:07
Joined
Jun 8, 2002
Messages
6,195
AdamO,

Is the function working for you? I am guessing it is since you are not gettign any error messages. Test it out. Disable the shift Key and see if you can open the db using the shift key and vice versa. The best way to test it is to create an AutoExec macro and have the macro call a message box.

I am using Access 97 and I have heard from others using newer versions that they had to use this line
Dim db As DAO.Database, prp As DAO.Property

Instead of
Dim db As Database, prp As Property

When that was the case, they had to set the reference to the DAO 3.6 as my instructions stated.

HTH
 

ghudson

Registered User.
Local time
Today, 17:07
Joined
Jun 8, 2002
Messages
6,195
Rob.Mills,

What did you adjust accordingly?

Did you set your reference to DAO 3.6 if you used
Dim db As DAO.Database, prp As DAO.Property

Instead of
Dim db As Database, prp As Property
 
Last edited:

Rob.Mills

Registered User.
Local time
Today, 17:07
Joined
Aug 29, 2002
Messages
871
Hey that fixed it. Thanks!!

The only things I adjusted was the password as you said, and I had named my command button something different so I went through the code and changed that. But adding DAO. to the variable types did the trick.
 

AdamO

Registered User.
Local time
Today, 22:07
Joined
Jun 26, 2002
Messages
40
ghudson,

Thanks for getting back.

Yes, it does seen to be working fine. The way to disable the shift key I presume is to enter an incorrect password.

I have tried both:

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

and

Dim db As Database, prp As Property

and both work ok with my Access 2000.

I did not quite follow your comments on References in Modules as this is very new to me. I did wonder if I was mis-interpreting anything which prompted my post. My file types here seemed to differ from your. Obviously worrying unnecessarily, I hope!
 

peterbowles

Registered User.
Local time
Today, 22:07
Joined
Oct 11, 2002
Messages
163
Hi
I have used you code for disabling the Shift key (really good piece of code)
I was just thinking is there a way of detecting if the key is enabled or disabled when the DB is opened and producing a msg box to inform the user
 

ghudson

Registered User.
Local time
Today, 17:07
Joined
Jun 8, 2002
Messages
6,195
This might require some more error trapping but it works for me...
Code:
'This function will allow you to test if the AllowBypassKey is turned On (enabled) or Off (disabled)
Public Function TestBypassKey() As Boolean
On Error GoTo Err_TestBypassKey

    Dim dbCurrent As Database

    Set dbCurrent = CurrentDb
    TestBypassKey = dbCurrent.Properties("AllowBypassKey")
    
    If TestBypassKey = True Then MsgBox "The BypassKey property has been enabled.", vbInformation, "AllowBypassKey = " & TestBypassKey
    If TestBypassKey = False Then MsgBox "The BypassKey property has been disabled.", vbInformation, "AllowBypassKey = " & TestBypassKey

Exit_TestBypassKey:
    Exit Function

Err_TestBypassKey:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_TestBypassKey

End Function
HTH
 
Last edited:

Mark Wild

Registered User.
Local time
Today, 22:07
Joined
Apr 9, 2003
Messages
126
Hi,

I agree with all that this is an excellent piece of code. I've adapted it slighty to include the toolbars being visible if the bypass is on, otherwise restricting users to a custom menu.

My problem is that I can no longer get users to type in thier password as the Tools menu is not there.

I have tried adding "Set Login Password" to my custom menu, but it is greyed out.

I guess everyone using security must have a way to get round this, but damned if I can find one!!!

Cheers
 

Rob.Mills

Registered User.
Local time
Today, 17:07
Joined
Aug 29, 2002
Messages
871
Here's some code that I've perfected for myself. It's a little modified from code I found in Access Advisor. Best thing I've found so far.

It's for anyone who likes to use MDE files for their frontends. Basically what it does is test whether or not the file is mde or mdb. Also works on adp or ade. Then it will set all properties the way you want set depending on what type. I have it keep everything available for the mdb file which is where I do the development. Then when I create the MDE file it will lock everything down. You have to create a form to open on startup to run all the procedures and then it can be closed. But it's great because I don't have to worry whether I've set the bypass to enabled or not. Have a look.

Private Function AddAppProperty( _
strName As String, _
varType As Variant, _
varValue As Variant) As Boolean

Dim dbs As Object
Dim prp As Variant

Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
Const conPropNotFoundError = 3270

If varType = DB_Text Then
If IsNull(varValue) Or varValue = vbNullString Then
On Error Resume Next
Set dbs = CurrentDb
dbs.Properties.Delete (strName)
Set dbs = Nothing
AddAppProperty = True
Exit Function
End If
End If

Set dbs = CurrentDb
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue
AddAppProperty = True

AddProp_Bye:
Set dbs = Nothing
Set prp = Nothing
Exit Function

AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If

End Function

Private Function IsCompiledFile() As Boolean
'Returns True if MDE or ADE this function
'Returns False if MDB or ADP

On Error GoTo Err

Dim strMDEADE As String
On Error Resume Next

'The ProjectType property is used to determine
'if the database is an MDB or ADP
If CurrentProject.ProjectType = acMDB Then
strMDEADE = CurrentDb.Properties("MDE").Value
Else
strMDEADE = CurrentProject.Properties("MDE").Value
End If

'The next line is the original Microsoft code.
'I have expanded it for readability.
'IsCompiledFile =
'(Err.Number = 0 And strMDEADE = "T")

If Err.Number = 0 And strMDEADE = "T" Then
IsCompiledFile = True
Else
IsCompiledFile = False
End If

Exit Function

Err:

MsgBox Err.Description

End Function

Public Function SetDbProperties()
'Uses the IsCompiledFile function to determine what kind of database this is.
'Sets the database startup properties accordingly

On Error GoTo Err

DoCmd.Hourglass (True)

Dim strProjectName As String
Dim strStartupMenuBar As String
Dim strAppIcon As String
Dim strStartupShortcutMenubar As String

On Error Resume Next

'The following variables will need to be customized for each db
strProjectName = "Cash Processor"
strStartupMenuBar = vbNullString
strAppIcon = "C:\Documents and Settings\All Users\Documents\Money.bmp"
strStartupShortcutMenubar = vbNullString

'The Select Case will setup the properties depending
'on whether the db is a development or a user file
Select Case IsCompiledFile
Case True 'User file
Call AddAppProperty("AppTitle", DB_Text, strProjectName)
Call AddAppProperty("StartupForm", DB_Text, "frmSplash")
Call AddAppProperty("StartupShowDBWindow", DB_Boolean, False)
Call AddAppProperty("StartupShowStatusbar", DB_Boolean, True)
Call AddAppProperty("StartupMenuBar", DB_Text, strStartupMenuBar)
Call AddAppProperty("AllowShortcutMenus", DB_Boolean, False)
Call AddAppProperty("AllowFullMenus", DB_Boolean, False)
Call AddAppProperty("AllowBuiltInToolbars", DB_Boolean, False)
Call AddAppProperty("AllowToolbarChanges", DB_Boolean, False)
Call AddAppProperty("AllowBreakIntoCode", DB_Boolean, False)
Call AddAppProperty("AllowSpecialKeys", DB_Boolean, False)
Call AddAppProperty("AllowBypassKey", DB_Boolean, False)
Call AddAppProperty("AppIcon", DB_Text, strAppIcon)
Call AddAppProperty("StartupShortcutMenubar", DB_Text, strStartupShortcutMenubar)
Call AddAppProperty("UseAppIconForFrmRpt", DB_Boolean, True)
Call Application.SetOption("ShowWindowsInTaskbar", False)
CommandBars("Print Preview").Enabled = False
Case False 'Developer's file
Call AddAppProperty("AppTitle", DB_Text, "Development - " & strProjectName)
Call AddAppProperty("StartupForm", DB_Text, "frmSplash")
Call AddAppProperty("StartupShowDBWindow", DB_Boolean, True)
Call AddAppProperty("StartupShowStatusbar", DB_Boolean, True)
Call AddAppProperty("StartupMenuBar", DB_Text, strStartupMenuBar)
Call AddAppProperty("AllowShortcutMenus", DB_Boolean, True)
Call AddAppProperty("AllowFullMenus", DB_Boolean, True)
Call AddAppProperty("AllowBuiltInToolbars", DB_Boolean, True)
Call AddAppProperty("AllowToolbarChanges", DB_Boolean, True)
Call AddAppProperty("AllowBreakIntoCode", DB_Boolean, True)
Call AddAppProperty("AllowSpecialKeys", DB_Boolean, True)
Call AddAppProperty("AllowBypassKey", DB_Boolean, True)
Call AddAppProperty("AppIcon", DB_Text, strAppIcon)
Call AddAppProperty("StartupShortcutMenubar", DB_Text, strStartupShortcutMenubar)
Call AddAppProperty("UseAppIconForFrmRpt", DB_Boolean, True)
Call Application.SetOption("ShowWindowsInTaskbar", True)
CommandBars("Print Preview").Enabled = True
End Select

Exit Function

Err:

MsgBox Err.Description

End Function
 
M

mission2java_78

Guest
You need to reference DAO when working with the DAO object model. If you dont access gets confused. Also check your reference so that DAO 3.6 is above any ADO reference...otherwise when you

Dim db as Database
Dim rs as Recordset

Access thinks your dimming an ADO object.

Jon
 

Users who are viewing this thread

Top Bottom