By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

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

elenaA
P: 42
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
2 Weeks Ago #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

Share this Question
Share on Google+
6 Replies


P: 72
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
2 Weeks Ago #2

elenaA
P: 42
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
2 Weeks Ago #3

P: 72
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.
2 Weeks Ago #4

elenaA
P: 42
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
2 Weeks Ago #5

P: 72
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.
2 Weeks Ago #6

elenaA
P: 42
Ok I will try to make this working
thank you
2 Weeks Ago #7

Post your reply

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