Trying to use this can't get it to work CurrentDb.Properties ("AllowShortcutMenus") = False (1 Viewer)

Db-why-not

Registered User.
Local time
Today, 04:43
Joined
Sep 17, 2019
Messages
155
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:
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:43
Joined
Oct 29, 2018
Messages
13,738
Hi. Just FYI... I think both of those properties require a restart of the DB before it takes effect.
 

Db-why-not

Registered User.
Local time
Today, 04:43
Joined
Sep 17, 2019
Messages
155
I'm not sure if I saved the function in the right place. I haven't created my own functions before. I saved it in a module.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:43
Joined
Oct 29, 2018
Messages
13,738
I'm not sure if I saved the function in the right place. I haven't created my own functions before. I saved it in a module.
Hi. What I am saying is I don't know how useful it would be for you to modify those properties at login time because the current logged in user will probably not be able to use them. They may have to log out and then log in again to see the changes.
 

Db-why-not

Registered User.
Local time
Today, 04:43
Joined
Sep 17, 2019
Messages
155
What would be a good way to enable and disable the special access keys and shortcut menus. I know that I can disable for the whole database with the privacy options menu. But I want to be able to enable and disable them depending on who is logging in to the database with VBA code. I can set up the database so those properties are already disabled prior to the database opening., but then I want to enable them if admin user logs in. IF a non admin user logs in I want those properties to remain disabled.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:43
Joined
Oct 29, 2018
Messages
13,738
What would be a good way to enable and disable the special access keys and shortcut menus. I know that I can disable for the whole database with the privacy options menu. But I want to be able to enable and disable them depending on who is logging in to the database with VBA code. I can set up the database so those properties are already disabled prior to the database opening., but then I want to enable them if admin user logs in. IF a non admin user logs in I want those properties to remain disabled.
Hi. Let me think about it. What would using special keys allow admins to do in your database? The normal "best practice" approach is to distribute ACCDE to all users, which pretty much limits them on what they can do. So, I almost want to say, just let the admins use the regular ACCDB instead.
 

Db-why-not

Registered User.
Local time
Today, 04:43
Joined
Sep 17, 2019
Messages
155
I might try using ACCDE . I haven't done it before but I think it should work. Once this database is done I don't think I'm going to have to modify it at all.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:43
Joined
Oct 29, 2018
Messages
13,738
I might try using ACCDE . I haven't done it before but I think it should work. Once this database is done I don't think I'm going to have to modify it at all.
Okay. For added security, rename the ACCDE to ACCDR before giving it to your users. Good luck!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:43
Joined
May 21, 2018
Messages
4,113
I have a public procedure and then call it in the forms load event

Code:
public Sub SetShortCutMenuPermissions(frm as access.form)
  Select case SomeUserLevel
    Case "Admin"
      frm.shortcutmenu = true
    case "User"
       frm.shortcutmenu = false
    .....
  end select
end sub

This works for me since my forms and reports are modal and keeps from getting to a blank db window.
 

Users who are viewing this thread

Top Bottom