Here is one way to do it: Only do this on a backup copy of your mdb.
It is very easy to "lock yourself out forever."
Create two buttons on the Startup form: one to call SetFullStartUpProperties
and another to callSetLimitedStartupProperties.
Change their visible property so that only you can see them.
If CurrrentUser() = "joe" Then
Me![btn1].Visible=True
Me![btn2].Visible=True
Else
Me![btn1].Visible=False
Me![btn2].Visible=False
End If
Click the Limited button, close the mdb and re-open.
Code behind the Limited button:
DoCmd.Hourglass True
SetLimitedStartupProperties
DoCmd.Hourglass False
MsgBox ("Limited start up options set.")
You will be locked out of the database window.
The *only way* to get it back is to click the Full Button.
This is why you have to practice on a copy!!!
Put this code in a module:
Sub SetFullStartupProperties()
ChangeProperty "StartupForm", dbText, "Startup",True
ChangeProperty "StartupShowDBWindow", dbBoolean, False,True
ChangeProperty "StartupShowStatusBar", dbBoolean, True,True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, True,True
ChangeProperty "AllowToolbarChanges", dbBoolean, True,True
ChangeProperty "AllowFullMenus", dbBoolean, True,True
ChangeProperty "AllowShortcutMenus", dbBoolean, True,True
ChangeProperty "AllowBreakIntoCode", dbBoolean, True,True
ChangeProperty "AllowSpecialKeys", dbBoolean, True,True
ChangeProperty "AllowBypassKey", dbBoolean, True,True
End Sub
Sub SetLimitedStartupProperties()
ChangeProperty "StartupForm", dbText, "Startup",True
ChangeProperty "StartupShowDBWindow", dbBoolean, False,True
ChangeProperty "StartupShowStatusBar", dbBoolean, True,True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False,True
ChangeProperty "AllowToolbarChanges", dbBoolean, False,True
ChangeProperty "AllowFullMenus", dbBoolean, False,True
ChangeProperty "AllowShortcutMenus", dbBoolean, False,True
ChangeProperty "AllowBreakIntoCode", dbBoolean, False,True
ChangeProperty "AllowSpecialKeys", dbBoolean, False,True
ChangeProperty "AllowBypassKey", dbBoolean, False,True
End Sub
Function ChangeProperty(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangeProperty_Err
Dim db As DAO.Database
Dim prp As DAO.Property
Const conPropNotFoundError = 3270
Set db = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True)
db.Properties.Append prp
' If we made it this far, it worked!
ChangeProperty = True
ChangeProperty_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function
ChangeProperty_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangeProperty_Exit
End Function