Disable shift key bypass

  • Thread starter Thread starter CompG
  • Start date Start date
C

CompG

Guest
Hi,
My question is how do I go about disabling the shift key bypass feature--what security measures do I have to take?

Thanks in advance.

Chris
 
You can do this by setting the AllowBypassKey property to false, but before doing so familiarize yourself with all the implications. I would suggest you read the help topics on AllowBypassKey and Startup Options, and browse the See Also help topics that are listed with them. The code below is what I use:

Function SetShiftKeyBypass(Setting As Boolean) As Boolean
'This function sets the value of the database's AllowBypassKey property,
'first creating that property if necessary. The setting will take effect
'the next time the database is opened. If it is False, the AutoExec
'macro and the Startup options will not be bypassed, even if the Shift
'key is pressed; if it is True, the Shift key will cause both the
'autoexec macro and the startup options to be bypassed, and the
'Database window to be displayed.
On Error GoTo Error_SetShiftKeyBypass
Dim db As Database
Dim prop As Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowBypassKey") = Setting
SetShiftKeyBypass = True
Exit_SetShiftKeyBypass:
Exit Function
Error_SetShiftKeyBypass:
'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
Set prop = db.CreateProperty("AllowBypassKey", dbBoolean, Setting)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function SetShiftKeyBypass did not complete successfully."
SetShiftKeyBypass = False
GoTo Exit_SetShiftKeyBypass
End If
End Function
Sub LockIt()
'Disables Shift key bypass for this database - BE CAREFUL - if you run this, and Startup options have been
'set to disable both full menus and display of the database window, once you close this copy of the database
'you will have no way to re-enable Shift key bypass
Dim x As Variant
x = SetShiftKeyBypass(False)
End Sub
Sub UnlockIt()
'Enables Shift key bypass for this database
Dim x As Variant
x = SetShiftKeyBypass(True)
End Sub
 
Thanks AlanS, but I have another question. Where exactly would I place this code? In a form or module, and how would I get the database to read it? I just don't understand that part of it. I recently took a look at the help files you told me to, and I understand all the implications involved, and I thank you for referring me to that.

Thanks again for your help. If I can get these questions answered, then I can move on to bigger and better things.

Also, is there any way to prevent the import of tables, forms, macros and such into another database?

Thanks.
 
Put all this code into a standard module, so its scope will be the entire application. In general, you get Access to read and execute each Sub or Function simply by referencing it in the normal way anywhere in VBA code, or in certain other contexts (such as query criteria). For this particular code, I simply display the module in Design view, position the insertion point at the top of the Sub I want to run (LockIt or UnlockIT), and press F5. The change takes effect the next time the database is opened.

Preventing import or export of objects could be done by turning off Display Full Menus, Display Database Window and Allow Special Access Keys in Startup Options. If your users are sophisticated enough to know about the Shift key bypass, you will also need to keep a production copy (in which to do maintenance) and a working copy (which will have the AllowBypassKey property set to False). Once you set the AllowBypassKey property to False and close the database, you will never be able to view or manipulate that copy's objects again, so it is crucial that you maintain the production copy for maintenance.

Another issue with all this is that whenever you do maintenance on the production copy and use it to create a new working copy, you will wipe out the table data in the existing working copy. The only solutions to that conundrum that I'm aware of are either keeping all the data in another (back end) database and linking your application to it, or utilizing some more complex login/password security regimen (either the cumbersome but effective system built into Access or another one you design or buy).

Hope this helps.
 
CompG, I hav an application where I faced about the same problem. My solution was: create a user table with an access level field ("1" - "3" in my case)and associated form; after my splash screen displays, a password screen is opened; database properties are turned on or off depending on a code embed list of "privilidges" for each access level; I also embeded a password detection (not stored in the user table) in the code to insure that I can always get in; the setting of database properties is accomplished a slightly modified plagerism of the set properties example found in the included sample application ("Northwind" I believe); I included a list of enabled/disabled forms during the properties setting operation. It sounds more complicated than it really is. Make sure only the most priviledged access level can open the add, delete, modify users.
 
None of this is actually secure...........
Anyone can simply create a new empty database and import all of the objects into it. Or they can simply link to the database in question. Also you can set the Shift Key property remotely from a completely seperate database. I do this all the time so that I don't have to place the Shift Key code into the databases.

Disabling the Shift Key will only keep amateurs away from accessing/altering the data stored in your tables.

I posted this info so that you would not have a false sense of security by implementing this approach.

HTH
RDH

[This message has been edited by R. Hicks (edited 08-19-2001).]
 

Users who are viewing this thread

Back
Top Bottom