By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

Preventing User accessiblity to .mdb

P: n/a
RLN
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 ***
Jul 1 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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:
http://www.ffdba.com/downloads/Reset...Properties.htm
(This defaults all the properties; one would change the boolean and
string values to disable them.)

On Jul 1, 3:36*pm, RLN <nospam...@devdex.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 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 Developersdexhttp://www.developersdex.com***
Jul 2 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.