Results 1 to 10 of 10
  1. #1
    ewatson
    Guest

    Protect database

    Hi All,
    I know how to use a switchboard to make it so no one can fool with the data and limit themselves to only switchboard items but they can bypass it by holding down the shift key. is there a way to protect that with a password or something so only I can get past the switchboard. attached is the db I'm working on
    Thanks,
    Ed

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    La Verne, California, USA
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect database

    I would suggest you look at allowbypasskey in the on line help.
    <img src=/S/exclamation.gif border=0 alt=exclamation width=15 height=15>

  3. #3
    ewatson
    Guest

    Re: Protect database

    Thanks Preston,
    I looked at it but it doesn't tell me how I will get in to modify the db once it is set up to not allow the shift key.

    Ed

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect database

    That's up to how you choose to implement a "back door". You need to choose a way to allow certain users to run code that sets allowbypasskey back to true again.

    The way I deal with it is to check either currentuser() if I am doing something that uses workgroup security, or the NT id if I'm doing something that doesn't use workgroup security, and if they belong to a set of "special people" I prompt to see if they want the shift key turned back on (i.e. allowbypasskey set back to true) for the next use of the database. If you have no "special users", then you'll have to use security by obscurity; for instance watch some special key combination done in some particular place.

    I also always make sure allowbypasskey is turned off everytime the database is started normally, so there's no need for the "special users" to remember to do something special to turn it off again.

  5. #5
    ewatson
    Guest

    Re: Protect database

    Doug,
    I think I get what you are saying but I'm not sure how to do it. do I just end up making a diffrent key sequence to take the place of the shift key? Because that would work too!

    Ed

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect database

    No - you make a key sequence, prompt, magic button, or whatever to set allowbypasskey back to true again (look at the code for turning off allowbypasskey; it should be apparent how to turn it back on again). Then the next time you open the database you'll be able to use the shift key as usual to bypass the startup conditions.

    So, no, you're not making a key to take the place of the shift key; you're making a key (button, prompt, or whatever) that allows you to use the shift key again!

  7. #7
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Protect database

    I received a tip from ElementK Tips (<A target="_blank" HREF=http://www.elementktips.com>http://www.elementktips.com</A>) that looks as if it would be exactly what you are looking for. Since their tips are copyrighted, I don't believe it would be proper (or legal) to repost it in its entirety here. If you can't find it in their archive of tips, I could forward it to you directly.

    Here is the raw code that was given in the tip, if that would be enough:
    <hr> Function PreventBypass() As Boolean
    Set prp = CurrentDb.CreateProperty("AllowBypassKey", _
    dbBoolean, False, True)
    CurrentDb.Properties.Append prp
    Set prp = Nothing
    End Function
    <hr>

  8. #8
    ewatson
    Guest

    Re: Protect database

    If you could forward it to me direst that would be great
    ewatson@comsectech.com
    Thanks
    Ed

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Protect database

    David,

    That code will work to set the allowbypasskey property to false, but it doesn't provide any means for the programmer to get back into the database down the road.

    The method I've used for that in the past is a command line argument. In Tools-->Options-->Advanced, there is a place to enter a command line argument, and I usually use something like DEV_MODE=-1 when I'm developing and DEV_MODE=0 when I lock the project down.

    In the startup code, I use the Command() function to see if DEV_MODE=-1, and if it does (meaning that I either set it manually in the Tools menu or I passed a command line argument in at startup), I turn on any properties I need to edit the database. If I have DEV_MODE=0 set in the Tools menu, I can start the database using something like this:

    "C:Program FilesMicrosoft OfficeOfficeMsaccess.exe" C:ProjectsMyDatabase.mdb /cmd "DEV_MODE=-1"

    That will reset the command lien argument and my startup code will change the settings to allow me back into the database design. I use something like this is the startup code:

    Dim varCmd as variant

    varCmd = Command()
    If varCmd = "DEV_MODE=-1" Then
    '... do whatever
    End If
    Charlotte

  10. #10
    Lounger
    Join Date
    Jan 2001
    Location
    Indiana
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect database

    Ed,

    Here is the code you are looking for. Note the second function at the bottom. Use a hidden (transparent) button, via a macro, to run the "un-lock" code. I had a message line so that you know when you have pressed the button. Make the message generic, just in case a user would happen to accidently press it also. They would not know the "true" meaning of the message.

    Option Compare Database
    Option Explicit

    Sub SetByPassProperty()
    Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, False
    End Sub

    'This function disable the Shift Key from pausing the database start up and allowing users to underlying tables, queries,
    'etc. Even though they can hold the shift key down, it will not stop that "startup" sequence.

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant)
    Dim dbs As Object, prp As Variant
    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
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    dbs.Properties.Append prp
    Resume Next

    Else

    ChangeProperty = False
    Resume Change_Bye

    End If
    End Function

    'Use a hidden "back-door" to run this function. If not, then you may not get back in.

    Function AllowByPass()

    CurrentDb.Properties("AllowBypassKey") = True
    MsgBox "What's Uppppp!"

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •