Admin Log In

Zippyfrog

Registered User.
Local time
Today, 14:14
Joined
Jun 24, 2003
Messages
103
I am not quite sure how I should go about this...

A couple of days ago, I came across a post that had an excellent example of a login/password screen for the database. The file was called SecurityExample2000.zip, although I can't seem to find the post at the moment.

Anyways, I want to implement something like that in my database, however, I would like to change one thing: If the user is logged in as Admin, frmAdmin will show up. And for everyone else, they go to the Switchboard form. What I did is declared "Admin" as a string value:

Dim Admin as String

then said

If Combo4 = Admin, then all the code and where it says .openform "Switchboard" I replaced with .openform "frmAdmin" Then the else part of the statement was the original code. However, I can't seem to get it to work. What should I do?? Any help would be appreciated. Thanks.

-Chris

(Here is the code that was included in the database. The way this code is, everyone goes to the switchboard. I want to change it so that If Admin is chosen from Combo4 and the password is correct, then frmAdmin will open, but for everyone else when their password is correct, the switchboard form opens.)

Private Sub btnLogin_Click()
'check for nulls
If IsNull(Me.txtPassword) Or IsNull(Me.Combo4) Then
MsgBox "You must enter a User Name and Password."
If IsNull(Me.Combo4) Or Me.Combo4 = "" Then
Me.Combo4.SetFocus
Me.Combo4.Dropdown
Else
Me.txtPassword.SetFocus
End If
Exit Sub
End If

Dim strTheUser As String
Dim strThePassword As String


If Me.txtPassword = Me.UserPassword Then 'CORRECT do log in
'set global variables to be used as default value
strTheUser = Me.TheUserName
strThePassword = Me.UserPassword
'update the LastLoggedIn field in the tblSystem table

With DoCmd
.SetWarnings False
.OpenQuery "qryUpdateLastLoggedIn"
.SetWarnings True
'open the thread list form
.Close
.OpenForm "Switchboard"
End With

Else 'INCORRECT
attempts = attempts + 1 'allow 3 attempts before exiting
If attempts = 3 Then
MsgBox "The password was incorrect on 3 occasions, this system will now close, see the database administrator to reset your user profile."
DoCmd.Quit
Else
MsgBox "The password was incorrect, you have only " & 3 - attempts & " attempts left before this program closes."
Me.txtPassword = ""
Me.txtPassword.SetFocus
End If
End If
End Sub
 
Admin

Try putting a nested If Else statement at the point where you open the form

i.e. If combo4.value = "admin" then
.openform "frmAdmin"
else
.Openform "frmUser"
end if
 

Users who are viewing this thread

Back
Top Bottom