[AccessD] How To Undo Disabled Shift Bypass

Stuart McLachlan stuart at lexacorp.com.pg
Thu Feb 24 15:47:23 CST 2011


Incidentally,   I often leave a trapdoor inside the applications.

I use a function to toggle the security state ( comment out particular properties depending on 
the requirement of the application)

Function Lockdown(state As Boolean)
SetProperty "AllowBypassKey", dbBoolean, Not state
SetProperty "AllowFullMenus", dbBoolean, Not state
SetProperty "AllowSpecialKeys", dbBoolean, Not state
SetProperty "AllowToolbarChanges", dbBoolean, Not state
SetProperty "AllowBuiltInToolbars", dbBoolean, Not state
SetProperty "AllowBreakIntoCode", dbBoolean, Not state
'SetProperty "AllowSHortcutMenus", dbBoolean, Not state
End Function

Public Function SetProperty(strPropName As String, _
                              varPropType As Variant, varPropValue As Variant) As Boolean
    On Error GoTo Err_SetProperty
    Dim db As DAO.Database, prp As DAO.Property
    Set db = CurrentDb
    db.Properties(strPropName) = varPropValue
    SetProperty = True
    Set db = Nothing
Exit_SetProperty:
    Exit Function
Err_SetProperty:
    If Err = 3270 Then        'Property not found
        Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
        db.Properties.Append prp
        Resume Next
    Else
        SetProperty = False
        MsgBox "SetProperty", Err.Number, Err.Description
        Resume Exit_SetProperty
    End If
End Function

If I am using my own user level security, in my login process I use something like:
         If AccessLevel = 5 Then
          MsgBox "Developer Mode! - Close and Reopen Using the Bypass key"
          Lockdown False
          DoCmd.Quit

You can also do something similar with a commandline switch and a Startup() function called 
from an AutoExec macro or your startup form.

Note that similar code to the above is used in the tollbox MDB, the only difference is that "db" 
is passed as a parameter to SetProperty, rather than being hard coded to CurrentDB.   

Note also that Setproperty() can also be used to set other things such as built in Copyright 
notices, Version Numbers etc  in the same or a different database and a similar 
GetProperty() function can be used to read them.


-- 
Stuart

On 25 Feb 2011 at 7:14, Stuart McLachlan wrote:

> "The normal way to fix this is to open a new Access file and import
> all the objects, then reset references, startup properties, and
> options."
> 
> Not for everyone.  :-)
> 
> I think you will find that quite a few of us have a similar module in
> little MDB that we keep in our toolboxes.  Still, it's good to remind
> people occassionally
> 
> 
> -- 
> Stuart
> 
> On 24 Feb 2011 at 7:40, Dan Waters wrote:
> 
> > Sure been quiet for a few days!  So this is something I finished
> > yesterday.
> > 
> > A few days ago, for about the hundredth time, I accidentally locked
> > myself out of an Access file by mistakenly running code to change
> > its properties, including setting the AllowShiftBypass property to
> > False.  The normal way to fix this is to open a new Access file and
> > import all the objects, then reset references, startup properties,
> > and options.  It´s a pain.
> > 
> > I recently did some work with OpenCurrentDatabase, and wondered if I
> > could make a utility to reset an Access file´s properties where that
> > file had its properties set to False.  And it worked!
> > 
> > Below is code that you can copy into a standard module in a new
> > Access file.  Name that new file AllowBypass.mdb, or something
> > similar.  Run the first procedure - this will ask you to select an
> > Access file, and it will then reset several properties to true so
> > that you can open it normally again.  
> > 
> > Hope someone can use this!
> > Dan
> > 
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 







More information about the AccessD mailing list