473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

elenaA
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
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

6 1986
cactusdata
214 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
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
Feb 8 '20 #3
cactusdata
214 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
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
Feb 8 '20 #5
cactusdata
214 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
42
Ok I will try to make this working
thank you
Feb 8 '20 #7

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

Similar topics

3
by: Rudi Groenewald | last post by:
Hi there... I use SQL server integrated security so when a user opens a database in access it prompts the username & password in a small popup box on connection, but I'd like to use my own...
2
by: MLH | last post by:
What's the simplest way to allow a user of an A97 app to change password?
7
by: Nerrad | last post by:
Hi, i am currently working on a project which requires me to create a form to allow the user to change their password. I know there is a user-level security login which is easier and safer but...
2
by: Felix Melendez | last post by:
Hi there! I'd like to know if anyone out there can give me a helping hand. I've developed an asp.net application that uses Forms Authentication. Question: I'd like to give users the ability...
2
by: pj | last post by:
I'm using asp.net 2.0 login controls, When a user forgets a password, they are sent an email with the new password. Two questions.... 1) how do I format the password that is being created to...
1
by: roshina | last post by:
Hi Iam facing a problem in my project, developing a web site for online shopping in ASP on windows XP using IIS server. All the validations are ok but the new password is not upadated in the data...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
3
by: stumo | last post by:
Hi I'm fairly new to access and as such my experience of VBA is somewhat limited. I have a login form which is linked to an "employees table" which asks for users to enter their name and...
7
by: Jesse Jones | last post by:
Any ideas on how to send info from one form into another domain or how to write a default value for a new user's password with a formula? Here's what I'm trying to do: design my database so that...
1
by: anishkgt | last post by:
Hi All, Just finished a login form but the user 1 can login with user 2 password. To validate the user i used dlookup. but don't know where i went. Does anyone have any experience with this ?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.