Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    allowshortcutmenues at dependand on user

    Hi Everyone



    i would like to be able to only allow certain users from having shortcutmenus with in access 2010 forms.

    when the database starts the login form displays that has this code on the login button

    Private Sub cmdLogin_Click()


    'Check to see if data is entered into the UserName combo box


    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.cboEmployee.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the password box


    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.txtPassword.SetFocus
    Exit Sub
    End If


    'Check value of password in tblEmployees to see if this matches value chosen in combo box


    If Me.txtPassword.Value = DLookup("strEmpPassword", "Employees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
    strAccess = DLookup("strAccess", "Employees", "[lngEmpID]=" & Me.cboEmployee.Value)
    'lngMyEmpID = DLookup("strAccess", "Employees", "[lngEmpID]=" & Me.cboEmployee.Value)
    UserFullName = DLookup("FullName", "Employees", "[lngEmpID]=" & Me.cboEmployee.Value)
    lngMyEmpID = Me.cboEmployee.Value



    'Close logon form and Main screen

    DoCmd.Close acForm, "Logon", acSaveNo
    DoCmd.OpenForm "Dashboard"


    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
    Me.txtPassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
    Application.Quit
    End If

    End Sub


    this works really well and opens the form "dashboard"

    based on the "strAccess" level i have managed to hide certain buttons and reports, again this is working as expected.

    what i am required to do is allow users with strAccess = "admin" to be able to view the shortcut menus when they right click.

    i have tried creating a module with this code in it

    Option Compare Database
    Option Explicit


    Public Function EnableStartupProperties()


    changeproperty "AllowShortcutMenus", dbBoolean, True


    End Function



    and then calling EnableStartupProperties if "strAcess"= Admin but i get an error "Expected Variable or Procedure, Not Module"

    any ideas as to how i can go about this.

    Many Thanks

    Steve

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What is 'changeproperty' - VBA is not recognizing it as a method.

    I don't think programmatically setting the project AllowShortcutMenu property is practical (if even possible) because requires restarting the db for the new setting to take effect. Forms have a ShortcutMenu property setting that can be programmatically set. The db AllowShortcutMenu property must be active for forms to have shortcut menu.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi June7

    thanks for the reply

    i did not realise that forms could have this set programmatically

    i have added this and all is working now.

    many thanks

    steve

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 11-18-2013, 02:20 PM
  2. Replies: 1
    Last Post: 07-20-2012, 05:35 PM
  3. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  4. Replies: 1
    Last Post: 08-13-2011, 04:44 AM
  5. Replies: 8
    Last Post: 06-30-2010, 10:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums