homeb0dy

login form v2 [broken]

May 11th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. Private Sub Command1_Click()
  2. Dim User As String
  3. Dim UserLevel As Integer
  4. Dim TempPass As String
  5. Dim ID As Integer
  6. Dim UserName As String
  7. Dim TempID As String
  8.  
  9.  
  10. If IsNull(Me.txtUserName) Then
  11. MsgBox "Please enter UserName", vbInformation, "Username required"
  12. Me.txtUserName.SetFocus
  13. ElseIf IsNull(Me.txtPassword) Then
  14. MsgBox "Please enter Password", vbInformation, "Password required"
  15. Me.txtPassword.SetFocus
  16. Else
  17. If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
  18. MsgBox "Invalid Username or Password!"
  19. Else
  20. TempID = Me.txtUserName.Value
  21. UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
  22. UserLevel = DLookup("[UserType]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
  23. TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
  24. UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
  25. DoCmd.Close
  26. If (TempPass = "password") Then
  27. MsgBox "Please change Password", vbInformation, "New password required"
  28. DoCmd.OpenForm "frmUserinfo", , , "[UserLogin] = " & UserLogin
  29. Else
  30. 'open different form according to user level
  31. If UserLevel = 1 Then ' for admin
  32. DoCmd.OpenForm "Admin Form"
  33. Else
  34. DoCmd.OpenForm "Navigation Form"
  35. End If
  36.  
  37. End If
  38. End If
  39. End If
  40. End Sub
  41.  
  42. Private Sub Form_Load()
  43. Me.txtUserName.SetFocus
  44. End Sub
Add Comment
Please, Sign In to add comment