Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Preventing User...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 30625 of 31576
Post > Topic >>

Preventing User accessiblity to .mdb

by RLN <nospamrln@[EMAIL PROTECTED] > Jul 1, 2008 at 02:36 PM

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 SetAccessAppProperties()
    '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.CommandBars("Menu Bar").Enabled = False

    'these toolbars have the DatabaseWindow icon on them by default
    DoCmd.ShowToolbar "Form View", acToolbarNo
    DoCmd.ShowToolbar "Print Preview", acToolbarNo
    ChangeProperty "AllowShortCutMenus", dbBoolean, False
    ChangeProperty "StartupShowDBWindow", dbBoolean, False
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
    ChangeProperty "AllowFullMenus", dbBoolean, False
    ChangeProperty "AllowToolbarChanges", dbBoolean, False
    ChangeProperty "AllowBreakIntoCode", dbBoolean, False
    ChangeProperty "AllowSpecialKeys", dbBoolean, False
    ChangeProperty "AllowBypassKey", dbBoolean, False

    Set db = Nothing
On Error GoTo 0

End Function


Public Function ResetAccessAppProperties()
    '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 ResetAccessAppProperties"

On Error Resume Next
    Set db = CurrentDb()
          
    db.Properties("StartupShowDBWindow") = True
    DoCmd.ShowToolbar "Form View", acToolbarYes
    DoCmd.ShowToolbar "Print Preview", acToolbarYes
    ChangeProperty "AllowShortCutMenus", dbBoolean, True
    ChangeProperty "StartupShowDBWindow", dbBoolean, True
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, True
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowToolbarChanges", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True

    'set MenuBar back to default with
    'Application.MenuBar = ""
    
    'hide the main menu bar from users
    Application.CommandBars("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 conPropNotFoundError = 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 = 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
<end code>



*** Sent via Developersdex http://www.developersdex.com
***
 




 2 Posts in Topic:
Preventing User accessiblity to .mdb
RLN <nospamrln@[EMAIL   2008-07-01 14:36:29 
Re: Preventing User accessiblity to .mdb
lyle fairfield <lyle.f  2008-07-01 18:36:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 23:09:51 CST 2008.