Hello
I have my own login form. To enter into db user must enter his user name and password. Now I want to make that user must change the password if passess 30 days since he last time change his password.
How Can i do that?
thank you
here is my code
Option Compare Database
Private Sub Command1_Click()
Dim UserName, Temppass As String
Dim UserLevel, ID As Integer
Dim TempLogin As TempVar
If IsNull(Me.txtLoginID) Then
MsgBox "Please enter UserID", vbInformation, "UserID requeired"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password requeired"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("UserID", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "' And password = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid LoginID or Password!"
Else
TempVars!TempLogin = Me.txtLoginID.Value
UserName = DLookup("[Username]", "tblUser", "[UserLogin] = '" & Me.txtLoginID.Value & "'")
UserLevel = DLookup("[UserSecurity]", "tbluser", "[UserLogin] = '" & Me.txtLoginID.Value & "'")
Temppass = DLookup("[password]", "tblUser", "[UserLogin] = '" & Me.txtLoginID.Value & "'")
ID = DLookup("[Userid]", "tblUser", "[UserLogin] = '" & Me.txtLoginID.Value & "'")
'DoCmd.Close
If (Temppass = "password") Then
DoCmd.Close
MsgBox "Please change Password", vbInformation, "New password requeired"
DoCmd.OpenForm "ChangePassword", , , "[Userid] = " & ID
ElseIf IsNull(DLookup("answer1", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")) Or IsNull(DLookup("answer2", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")) Or IsNull(DLookup("answer3", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")) Then
DoCmd.Close
Msg = "Your security questions have not been set up. " _
& vbCr & "Do you want to set it up now?"
Style = vbYesNo + vbQuestion
Title = "Set Up Security Question?"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
DoCmd.OpenForm "ChangePassword", , , "UserID =" & ID
Exit Sub
End If
If Response = vbNo Then
'open different form according to user level
If UserLevel = 1 Then ' for admin
DoCmd.ShowToolbar "Ribbon", acToolbarYes
DoCmd.OpenForm "GlavniMeni"
Forms![GlavniMeni]!poljeAdminForm.Visible = True
Else
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.OpenForm "GlavniMeni"
Forms![GlavniMeni]!poljeAdminForm.Visible = False
End If
End If
Else
DoCmd.Close
'open different form according to user level
If UserLevel = 1 Then ' for admin
DoCmd.ShowToolbar "Ribbon", acToolbarYes
DoCmd.OpenForm "GlavniMeni"
Forms![GlavniMeni]!poljeAdminForm.Visible = True
Else
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.OpenForm "GlavniMeni"
Forms![GlavniMeni]!poljeAdminForm.Visible = False
End If
End If
End If
End If
End Sub