I have an access database (adp) with an login form. The form works great, logs in and then displays the default switchboard. I need it to baised on a value (numerical) to display the proper switchboard. The table that holds the user information has an UserID,Password, and DBAccess field. The dbaccess field holds the value (1,2,3,4,5). Ive created forms that i want to display after the login...eg bob is level 2 so level 2 form displays.
heres the code to the current login, need help adding in the next step to display the proper switchboard form.
Thanks.
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.UserID) Or Me.UserID = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.UserID.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.LoginPassword) Or Me.LoginPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.LoginPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.LoginPassword.Value = DLookup("EmpPassword", "tblLogin", "EmpLogin='" & Me.UserID.Value & "'") Then
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.LoginPassword.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
You need to check for a valid access level and then open the relevant form depending on the access level. I have a sample Login form (not using adp) on another thread on this forum. Have a look at message 44 or later it has a zip file http://forums.databasejournal.com/sh...t=45488&page=3
Module mod_display_menu will give some help with your coding.
Please contact me if you require further assistance with the module.