Solved

Prevent shift-enter

Posted on 2001-06-19
5
627 Views
Last Modified: 2008-02-26
Hello experts,
I'm looking for an opportunity to prevent any unauthorized user from using shift-enter to gain access to my access-db. You can call that 'private security'.
I do NOT want to create an mde or mde (if there is a way around).
In generally I think there could be a way in modifying
the functionality offered by menu Extras-Start.
But I'm not sure.
There should be also a way for me to have the required menu Extras.
It would be very helpful if I could get a code-snippet to realize that.
Is there a way?
Thank you for any help
  HStrix
0
Comment
Question by:HStrix
5 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 200 total points
ID: 6206706
without creating an MDE, there is absolutely NO way to prevent a malicious user from "importing" all of your objects from the "locked" db to a new db.

for that reason alone, you should consider using an MDE.

on top of that, if you store you data in access tables, there is also no way to prevent people from linking to your tables from another .mdb file and modifying data etc.

that being said, here's the function i use:

Public Function SetAllowBypassKey(bBypass As Boolean)

    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270
    Const strKey = "AllowBypassKey"
    Set dbs = CurrentDb
    On Error GoTo SetAllowBypassKeyErr
    If bBypass = False Then
      dbs.Properties(strKey) = False
    Else
      dbs.Properties(strKey) = True
    End If

If bBypass = True Then
   MsgBox "Enabled"
Else
   MsgBox "Disabled"
End If

SetAllowBypassKeyExit:
      Exit Function

SetAllowBypassKeyErr:
      If Err = conPropNotFoundError Then
    ' Property doesn't exist yet
    If bBypass = False Then
    ' Create the property
         Set prp = dbs.CreateProperty(strKey, dbBoolean, False)
      Else
         Set prp = dbs.CreateProperty(strKey, dbBoolean, True)
      End If
      dbs.Properties.Append prp
    ' Add it to the collection
      Resume SetAllowBypassKeyExit
    End If

End Function

call it from whereever (usually the debug window). the one argument is wether you want to enable (true) or disable (false) the shift-bypass key.

another note. i create a macro that calls this function when i need it. usually ctrl-shift-F5 (disable) / ctrl-shift-F6 (enable). the wierd key stroke combination usually ensures that no user can guess the correct keystrokes to enable the bypass key.

also be warned, that macros are NOT secure even when in a .mde file. so a truly smart user can import the autokeys macro, and figue it out that way...

good luck

dovholuk
0
 
LVL 2

Expert Comment

by:englishman
ID: 6206866
I use similar code to disable shift-bypass entry to my db of tables and I also set users and group permissions to zero. - Only having "owner access" makes reading these tables possible. This requires being part of the workgroup and knowing the password.
0
 
LVL 8

Expert Comment

by:dovholuk
ID: 6206945
englishman,

very true. however there are a multitude of access security crackers out there as well... lol.

if security is a major issue, access as a front-end is only "so good".  but as we all know, nothing is ever totally safe.

good comment though...


dovholuk
0
 
LVL 2

Expert Comment

by:WonHop
ID: 6207103
Hello scorp8.  This is the one that I use

Function CheckDisableShiftKey()
Dim strCmdLineText As String
  strCmdLineText = Command()
 ' Set roger = myset![ok]
  If strCmdLineText = "AllowBypassKey" Then
     ChangeProperty "AllowBypassKey", dbBoolean, True
     MsgBox "The application is now unlocked@" & _
        "The application quit now. You will now be able to open the database while holding down the
shift key.@" & _
        "To lock the application again open the database without the special command line parameter
found in this shortcut.", _
        vbOKOnly, "WARNING"
        DoCmd.Quit
  Else
     ChangeProperty "AllowBypassKey", dbBoolean, False
     DoCmd.ShowToolbar "Menu Bar", acToolbarNo
     
  End If
End Function
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
  Dim dbs As Database, prp As Property
  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

Put this in the Target of a shortcut
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Joni_Myer\Databases\Joni_Myer_051201.mdb"
/cmd "AllowByPassKey"

It is the path to the Access.exe and the path to your database.  

The /cmd "AllowByPassKey is your password to let you in the database.  
The password in the code is located:
If strCmdLineText = "AllowBypassKey" Then

You can change that to whatever you like.

The way the code works that I provided is you can only open the database by using the ShiftKey only
thru the shortcut.  The cmd line in the shortcut is the password that lets you in.  You will first get
a message that says it is now unlocked then it will close.  Then you can use the ShiftKey to open it.
  When you close the database, open it again without the shortcut with the password in it.  This will
lock it again.

WonHop
0
 

Author Comment

by:HStrix
ID: 6207393
Hello dovholuk,
I've incorporated your code and it worked GREAT!

Thank you very much
 
   HStrix

In addition I thank the other experts as well.
But only one can get the points.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question