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