Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Prevent shift-enter

Posted on 2001-06-19
5
Medium Priority
?
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 800 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

609 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