trentgaming
New member
- Local time
- Tomorrow, 01:12
- Joined
- May 27, 2020
- Messages
- 1
Can someone help me with my login form.
when I am trying to login with level 2 user nothing happens but in level 1 user it is all good here is the code:
Option Compare Database
Private Sub btnLogin_Click()
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim UserName As String
Dim TempID As String
If IsNull(Me.txtUserName) Then
MsgBox "Please enter UserName", vbInformation, "Username required"
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password required"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid Username or Password!"
Else
TempID = Me.txtUserName.Value
UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
'DoCmd.Close
If (TempPass = "password") Then
DoCmd.Close
'open different form according to user level
If UserLevel = 1 Then ' for admin
DoCmd.OpenForm "Main Form"
ElseIf UserLevel = 2 Then ' for user
DoCmd.OpenForm "Navigation Form"
End If
End If
End If
End If
End Sub
Private Sub Form_Load()
Me.txtUserName.SetFocus
End Sub
when I am trying to login with level 2 user nothing happens but in level 1 user it is all good here is the code:
Option Compare Database
Private Sub btnLogin_Click()
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim UserName As String
Dim TempID As String
If IsNull(Me.txtUserName) Then
MsgBox "Please enter UserName", vbInformation, "Username required"
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password required"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid Username or Password!"
Else
TempID = Me.txtUserName.Value
UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
'DoCmd.Close
If (TempPass = "password") Then
DoCmd.Close
'open different form according to user level
If UserLevel = 1 Then ' for admin
DoCmd.OpenForm "Main Form"
ElseIf UserLevel = 2 Then ' for user
DoCmd.OpenForm "Navigation Form"
End If
End If
End If
End If
End Sub
Private Sub Form_Load()
Me.txtUserName.SetFocus
End Sub