Please see below:
Code:
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim UserName As String
Dim TempID As String
Dim but As String
Dim SysID As String
Dim datPassDate As Date
Dim intDaysOld As Integer
If IsNull(Me.txtUserName) Then
MsgBox "Please Enter User Name", 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 & "'")
ID = DLookup("[ID]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
datPassDate = DLookup("[PDate]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
intDaysOld = Date - Nz(datPassDate, Date)
but = "Login"
SysID = Environ("username")
CurrentDb.Execute "INSERT INTO UserLog (User_name,Log_Type, Log_Time, Log_Date,Computer_User)" & " VALUES ('" & Me.txtUserName & "','" & but & "',Now(),Now(),'" & SysID & "')"
DoCmd.Close
If (TempPass = "password") Then
MsgBox "Please change Password", vbInformation, "New password required"
DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
ElseIf intDaysOld > 30 Then
MsgBox "Password Expired Please change Password", vbInformation, "New password required"
DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
Else
'open different form according to user level
If UserLevel = 1 Then ' for admin
DoCmd.OpenForm "Navigation Form"
ElseIf UserLevel = 2 Then ' for academic
DoCmd.OpenForm "Navigation Form"
ElseIf UserLevel = 3 Then ' for exam
DoCmd.OpenForm "Navigation Form"
Else
DoCmd.OpenForm "Main_Menu_2"
End If
End If
End If
End If
Also, if not already there you need to reset the PDate from frmUSerInfo when new password is entered.
Cheers,
Vlad