Hello all,
I have an Access 2007 database that I have set up to have a user id to log into. That is working perfectly. I want to add another item for the login to look at which will say something along the lines of "your password matched, and your security level is 2, so this switchboard will open" or "your password matched and your security level is 1, so this switchboard will open."
I'm not even sure quiet where to begin to do this.
Here is the code I am using for the log on
Any ideas on what I would modify to get this to do what I need?'Check to see if data is entered into the UserName combo box If IsNull(Me.Text0) Or Me.Text0 = "" Then MsgBox "You must enter a User Name.", vbOKOnly, "Required Data" Me.Text0.SetFocus Exit Sub End If 'Check to see if data is entered into the password box If IsNull(Me.Text3) Or Me.Text3 = "" Then MsgBox "You must enter a Password.", vbOKOnly, "Required Data" Me.Text3.SetFocus Exit Sub End If 'Check value of password in tblLogin to see if this 'matches value chosen in combo box If Me.Text3.Value = DLookup("Password", "user_id", _ "[ID]=" & Me.Text0.Value) Then 'Close logon form and open switchboard DoCmd.Close acForm, "Login", acSaveNo DoCmd.OpenForm "Friday Rents Dates" Else MsgBox "Password Invalid. Please Try Again", vbOKOnly, _ "Invalid Entry!" Me.Text3.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 admin.", _ vbCritical, "Restricted Access!" Application.Quit End If
Thanks!
Just store the security level and corresponding switchboard in a table and link each user to a particular level and switchboard. You can use Dlookup again to find which security level to announce and which switchboard (form) to open.
There are a few things to remember when using a form to open access to different security levels. You need to make sure the user can't close the form without the database exiting. You definitely want the form modal, and control the form exit through a button control. Disable the X in the upper right corner by setting the Close Button property to No.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks