Db-why-not
Registered User.
- Local time
- Yesterday, 19:43
- Joined
- Sep 17, 2019
- Messages
- 160
I'm trying to lock down my database so when admin user is logged in, only admin user has access to short cut menus. "Allowshortcutmenus" is this setting for right click shortcut menus? Im also trying to disable the special access keys for non admin accounts. I can't get it to work.
I saw some post about having to CreateProperty method to append it to the Properties collection. I didnt understand why you need to do that or how to do it exactly. Where do I save the function at?
I created the public function to create property
Code on my login form when the login button is clicked
Any tips will be appreciated.
I saw some post about having to CreateProperty method to append it to the Properties collection. I didnt understand why you need to do that or how to do it exactly. Where do I save the function at?
Microsoft Access Training: How To Use the “AllowByPassKey” Using VBA Code
As part of the Microsoft Access training used to teach VBA programmers, the “AllowByPassKey” became handy and a good example ....
accessdatabasetutorial.com
I created the public function to create property
Code:
Public Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
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 Entry
ChangeProperty = False
Resume Change_Bye
End If
End Function
Code on my login form when the login button is clicked
Code:
Private Sub cmd_login_Click()
Dim strcboPass As String
Dim strPassword As String
strcboPass = Me.cboUser.Column(1)
strPassword = Me.txtPassword
If strcboPass = strPassword Then
DoCmd.OpenForm "Welcome_Menu"
Me.Visible = False
Else
MsgBox "Login Unsuccessful"
End If
If Me.cboUser = "Admin" Then
DoCmd.SelectObject acTable, , True
DoCmd.ShowToolbar "Ribbon", acToolbarYes
'enable more account features for admin account
ChangeProperty "AllowByPassKey", dbBoolean, True
Else
'Hides navigation bar
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
'Hides Ribbon bar
DoCmd.ShowToolbar "Ribbon", acToolbarNo
'Removes special bypass keys and shortcut menu bars
ChangeProperty "AllowByPassKey", dbBoolean, False
End If
End Sub
Any tips will be appreciated.