Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Command1_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("[UserType]", "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
- MsgBox "Please change Password", vbInformation, "New password required"
- DoCmd.OpenForm "frmUserinfo", , , "[UserLogin] = " & UserLogin
- Else
- 'open different form according to user level
- If UserLevel = 1 Then ' for admin
- DoCmd.OpenForm "Admin Form"
- Else
- DoCmd.OpenForm "Navigation Form"
- End If
- End If
- End If
- End If
- End Sub
- Private Sub Form_Load()
- Me.txtUserName.SetFocus
- End Sub
Add Comment
Please, Sign In to add comment