Preventing User accessiblity to .mdb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RLN

    #1

    Preventing User accessiblity to .mdb

    RE: Access 2003
    Current setup is: Front end .mdb (Interface, queries, macros, etc) /Back
    end .mdb (Database Tables)

    I'm trying to write some code that will prevent users from getting into
    the code (ie. right clicking for form design mode, F11 for the
    container, etc.)

    I'm testing this with two buttons on a form in a very simple app
    containing one table with 3 columns, 2 rows of data and one form based
    on the table I just described.

    This form has two buttons:
    "Set Access App Properties for User"
    "Set Access App Properties for Developer"

    (A word about ".mde's: I know you might suggest making an .mde and
    saving off the .mdb as source to the developer. I have way too much
    code in my production app at this point, and I'm nervous about making
    the .mde for fear it won't run properly and will generate loads of more
    errors that frankly, I don't have time to fix at this point. Deployment
    is about 5 days away and I can't risk a setback that the .mde might
    bring to my project. To that end, I'm trying to set these properties
    with code to better secure my applicaiton.

    Basically in my test app here when I click
    "Set Access Properties for User" I need these removed:
    -right-click capability
    -ability to press f11 to get to the DB.
    -menus to be removed that would allow them to go into design mode and
    create or modify objects.

    ...then when I click "Set Access Properties for Developer"
    I need the above restored.


    Here is what I have so far but it is not working right:

    <begin code>
    Public Function SetAccessAppPro perties()
    'This is run when "Set Access Properties for User" is clicked
    'This sets the properties at the Microsoft Access Development Tool
    level normally done via Tools/Options.

    Dim db As Database

    On Error Resume Next
    Set db = CurrentDb()

    'hide the main menu bar from users
    Application.Com mandBars("Menu Bar").Enabled = False

    'these toolbars have the DatabaseWindow icon on them by default
    DoCmd.ShowToolb ar "Form View", acToolbarNo
    DoCmd.ShowToolb ar "Print Preview", acToolbarNo
    ChangeProperty "AllowShortCutM enus", dbBoolean, False
    ChangeProperty "StartupShowDBW indow", dbBoolean, False
    ChangeProperty "AllowBuiltinTo olbars", dbBoolean, False
    ChangeProperty "AllowFullMenus ", dbBoolean, False
    ChangeProperty "AllowToolbarCh anges", dbBoolean, False
    ChangeProperty "AllowBreakInto Code", dbBoolean, False
    ChangeProperty "AllowSpecialKe ys", dbBoolean, False
    ChangeProperty "AllowBypassKey ", dbBoolean, False

    Set db = Nothing
    On Error GoTo 0

    End Function


    Public Function ResetAccessAppP roperties()
    'This is run when "Set Access Properties for Developer" is clicked
    'This sets the properties back at the Microsoft Access Development
    Tool level normally done via Tools/Options.

    Dim db As Database

    MsgBox "Begin ResetAccessAppP roperties"

    On Error Resume Next
    Set db = CurrentDb()

    db.Properties(" StartupShowDBWi ndow") = True
    DoCmd.ShowToolb ar "Form View", acToolbarYes
    DoCmd.ShowToolb ar "Print Preview", acToolbarYes
    ChangeProperty "AllowShortCutM enus", dbBoolean, True
    ChangeProperty "StartupShowDBW indow", dbBoolean, True
    ChangeProperty "AllowBuiltinTo olbars", dbBoolean, True
    ChangeProperty "AllowFullMenus ", dbBoolean, True
    ChangeProperty "AllowToolbarCh anges", dbBoolean, True
    ChangeProperty "AllowBreakInto Code", dbBoolean, True
    ChangeProperty "AllowSpecialKe ys", dbBoolean, True

    'set MenuBar back to default with
    'Application.Me nuBar = ""

    'hide the main menu bar from users
    Application.Com mandBars("Menu Bar").Enabled = True

    Set db = Nothing

    On Error GoTo 0

    End Function


    Public Function ChangeProperty( strPropName As String, varPropType As
    Variant, varPropValue As Variant) As Integer

    Dim dbs As Database
    Dim prp As Property
    Const conPropNotFound Error = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err

    MsgBox "Changing property for: " & " & strpropname & " - " &
    varproptype & " - " & varpropvalue"

    dbs.Properties( strPropName) = varPropValue
    ChangeProperty = True

    Change_Bye:
    Exit Function


    Change_Err:
    If Err = conPropNotFound Error Then ' Property not found.
    Set prp = dbs.CreatePrope rty(strPropName , varPropType, varPropValue)
    dbs.Properties. Append prp
    Resume Next
    Else
    ' Unknown error.
    ChangeProperty = False
    Resume Change_Bye
    End If
    End Function
    <end code>



    *** Sent via Developersdex http://www.developersdex.com ***
  • lyle fairfield

    #2
    Re: Preventing User accessiblity to .mdb

    I suggest that you consider setting these properties from a second
    application; in that way the state of the properties will not
    interfere with your code's ability to set them.
    For an example see:

    (This defaults all the properties; one would change the boolean and
    string values to disable them.)

    On Jul 1, 3:36 pm, RLN <nospam...@devd ex.comwrote:
    RE: Access 2003
    Current setup is: Front end .mdb (Interface, queries, macros, etc) /Back
    end .mdb (Database Tables)
    >
    I'm trying to write some code that will prevent users from getting into
    the code (ie. right clicking for form design mode, F11 for the
    container, etc.)
    >
    I'm testing this with two buttons on a form in a very simple app
    containing one table with 3 columns, 2 rows of data and one form based
    on the table I just described.
    >
    This form has two buttons:
    "Set Access App Properties for User"
    "Set Access App Properties for Developer"
    >
    (A word about ".mde's:  I know you might suggest making an .mde and
    saving off the .mdb as source to the developer.  I have way too much
    code in my production app at this point, and I'm nervous about making
    the .mde for fear it won't run properly and will generate loads of more
    errors that frankly, I don't have time to fix at this point.  Deployment
    is about 5 days away and I can't risk a setback that the .mde might
    bring to my project.  To that end, I'm trying to set these properties
    with code to better secure my applicaiton.
    >
    Basically in my test app here when I click
    "Set Access Properties for User" I need these removed:
    -right-click capability
    -ability to press f11 to get to the DB.
    -menus to be removed that would allow them to go into design mode and
    create or modify objects.
    >
    ..then when I click "Set Access Properties for Developer"
    I need the above restored.
    >
    Here is what I have so far but it is not working right:
    >
    <begin code>
    Public Function SetAccessAppPro perties()
        'This is run when "Set Access Properties for User" is clicked
        'This sets the properties at the Microsoft Access Development Tool
    level normally done via Tools/Options.
    >
        Dim db As Database
    >
    On Error Resume Next
        Set db = CurrentDb()
    >
        'hide the main menu bar from users
        Application.Com mandBars("Menu Bar").Enabled = False
    >
        'these toolbars have the DatabaseWindow icon on them by default
        DoCmd.ShowToolb ar "Form View", acToolbarNo
        DoCmd.ShowToolb ar "Print Preview", acToolbarNo
        ChangeProperty "AllowShortCutM enus", dbBoolean, False
        ChangeProperty "StartupShowDBW indow", dbBoolean, False
        ChangeProperty "AllowBuiltinTo olbars", dbBoolean, False
        ChangeProperty "AllowFullMenus ", dbBoolean, False
        ChangeProperty "AllowToolbarCh anges", dbBoolean, False
        ChangeProperty "AllowBreakInto Code", dbBoolean, False
        ChangeProperty "AllowSpecialKe ys", dbBoolean, False
        ChangeProperty "AllowBypassKey ", dbBoolean, False
    >
        Set db = Nothing
    On Error GoTo 0
    >
    End Function
    >
    Public Function ResetAccessAppP roperties()
        'This is run when "Set Access Properties for Developer" is clicked
        'This sets the properties back at the Microsoft Access Development
    Tool level normally done via Tools/Options.
    >
        Dim db As Database
    >
        MsgBox "Begin ResetAccessAppP roperties"
    >
    On Error Resume Next
        Set db = CurrentDb()
    >
        db.Properties(" StartupShowDBWi ndow") = True
        DoCmd.ShowToolb ar "Form View", acToolbarYes
        DoCmd.ShowToolb ar "Print Preview", acToolbarYes
        ChangeProperty "AllowShortCutM enus", dbBoolean, True
        ChangeProperty "StartupShowDBW indow", dbBoolean, True
        ChangeProperty "AllowBuiltinTo olbars", dbBoolean, True
        ChangeProperty "AllowFullMenus ", dbBoolean, True
        ChangeProperty "AllowToolbarCh anges", dbBoolean, True
        ChangeProperty "AllowBreakInto Code", dbBoolean, True
        ChangeProperty "AllowSpecialKe ys", dbBoolean, True
    >
        'set MenuBar back to default with
        'Application.Me nuBar = ""
    >
        'hide the main menu bar from users
        Application.Com mandBars("Menu Bar").Enabled = True
    >
        Set db = Nothing
    >
    On Error GoTo 0
    >
    End Function
    >
    Public Function ChangeProperty( strPropName As String, varPropType As
    Variant, varPropValue As Variant) As Integer
    >
        Dim dbs As Database
        Dim prp As Property
        Const conPropNotFound Error = 3270
    >
        Set dbs = CurrentDb
     On Error GoTo Change_Err
    >
        MsgBox "Changing property for: " & " & strpropname & " - " &
    varproptype & " - " & varpropvalue"
    >
        dbs.Properties( strPropName) = varPropValue
        ChangeProperty = True
    >
    Change_Bye:
     Exit Function
    >
    Change_Err:
     If Err = conPropNotFound Error Then ' Property not found.
        Set prp = dbs.CreatePrope rty(strPropName , varPropType, varPropValue)
        dbs.Properties. Append prp
        Resume Next
     Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
        End If
    End Function
    <end code>
    >
    *** Sent via Developersdexht tp://www.developersd ex.com***

    Comment

    Working...