Solved

Prevent shift-enter

Posted on 2001-06-19
5
628 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

839 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