467,864 Members | 1,837 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

How to change password every 30 days in your ms access login form

elenaA
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
Feb 8 '20 #1

✓ answered by cactusdata

Whenever the password is changed, record that in a field in tblUser:

Expand|Select|Wrap|Line Numbers
  1. LastChangedPassword.Value = Now
During login, check the days passed since the last change of password:

Expand|Select|Wrap|Line Numbers
  1. If DateDiff("d", LastChangedPassword, Now) > 30 Then
  2.     ' Call form to change the password.
  3. End If

  • viewed: 1681
Share:
6 Replies
cactusdata
Expert 128KB
Whenever the password is changed, record that in a field in tblUser:

Expand|Select|Wrap|Line Numbers
  1. LastChangedPassword.Value = Now
During login, check the days passed since the last change of password:

Expand|Select|Wrap|Line Numbers
  1. If DateDiff("d", LastChangedPassword, Now) > 30 Then
  2.     ' Call form to change the password.
  3. End If
Feb 8 '20 #2
elenaA
Where in my code for login procedure I have to put that?

If DateDiff("d", LastChangedPassword, Now) > 30 Then
' Call form to change the password.
End If

I make field in tblUser (LastChangedPassword, date/time, =now()?

did i make this correct?
thanks
Feb 8 '20 #3
cactusdata
Expert 128KB
It's up to you where to modify your code to perform the check. It's only you who knows how the login procedure should run.

The field data type is correct.
Feb 8 '20 #4
elenaA
Yes I understand,
I want to put this when user try to login
where do you suggest me is best to put it? i am quite new in vba programing...
thank you
can you give me example so i will try
thanks
Feb 8 '20 #5
cactusdata
Expert 128KB
It's difficult to read your code, and I don't have the forms.

Make the check after successful login. Then call the form to change password if the checks tells to do so. That should be it.
Feb 8 '20 #6
elenaA
Ok I will try to make this working
thank you
Feb 8 '20 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Rudi Groenewald | last post: by
2 posts views Thread by Felix Melendez | last post: by
3 posts views Thread by =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.