Hi,
I've created a log in system with a tutorial I've found on YouTube. It simply redirects users to a specific form after a successful log in. Here is the code:
The users are defined in tabel "tblUsers". All users are now redirected to the form "frmMenu" which is good.
However, I would like to know how to add an exception. For example
1) All users should be redirected to frmMenu after a successful log in. (Check)
2) The user called "Management" should be redirected to an other form "frmMgm"
I've searched on the internet on how to do this but without luck. (forums.asp.net/t/1775325.aspx/1)
So in short:
IF user "Management" logs in THEN redirect to frmMgm (or whatever form)
Thanks in advance,
I've created a log in system with a tutorial I've found on YouTube. It simply redirects users to a specific form after a successful log in. Here is the code:
Code:
Public Sub Login()
On Error GoTo ErrorHandler:
If IsNull([cboUser]) = True Then 'Hier wordt gechecked voor de UserName
MsgBox "Username is required"
ElseIf IsNull([txtPassword]) = True Then 'Hier wordt gechecked voor de Password
MsgBox "Password is requ;'/['ired"
Else
'Vergelijk waarden van txtPassword met de bewaarde Password in de tabel tblUsers
If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") Then
strUser = Me.cboUser.Value 'Zet de waarde van strUser gedeclareerd als globale variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") 'Zet de waarde van strRole gedeclareerd als globale variable
DoCmd.Close acForm, "frmLogin", acSaveNo
MsgBox "Welcome Back, " & strUser, vbOKOnly, "Welcome"
DoCmd.OpenForm "frmMenu", acNormal, "", "", , acNormal
Else
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
intLogAttempt = intLogAttempt + 1
txtPassword.SetFocus
End If
End If
'Hier wordt gekeken of de gebruiker vaker dan 3X foutief probeert in te loggen. In dat geval sluit te applicatie: Application.Quit
If intLogAttempt = 3 Then
MsgBox "You do not have access to this system." & vbCrLf & vbCrLf & _
"The system will now shutdown for safety reasons.", vbCritical, "Restricted Access!"
Application.Quit
End If
ErrorHandler:
End Sub
The users are defined in tabel "tblUsers". All users are now redirected to the form "frmMenu" which is good.
However, I would like to know how to add an exception. For example
1) All users should be redirected to frmMenu after a successful log in. (Check)
2) The user called "Management" should be redirected to an other form "frmMgm"
I've searched on the internet on how to do this but without luck. (forums.asp.net/t/1775325.aspx/1)
So in short:
IF user "Management" logs in THEN redirect to frmMgm (or whatever form)
Thanks in advance,
Last edited: