log in (1 Viewer)

goldstar19821982

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 17, 2008
Messages
78
Hello all,

I wanted to create a form which allows passwords to be changed.

Currently i have a log in form where the client enters their username and password to enter the system. but if they require changes to be made to their password is it possible to do this.

i was thinking something in the form of:

txtclient = client would need to enter their username
Then txtoldpassword
Then another two text boxes to confirm their new password

I have a password table in which i have the clientsname and their passwords stored.

Any help or samples would be appreciaeted
 

Rabbie

Super Moderator
Local time
Today, 04:16
Joined
Jul 10, 2007
Messages
5,906
Hello all,

I wanted to create a form which allows passwords to be changed.

Currently i have a log in form where the client enters their username and password to enter the system. but if they require changes to be made to their password is it possible to do this.

i was thinking something in the form of:

txtclient = client would need to enter their username
Then txtoldpassword
Then another two text boxes to confirm their new password

I have a password table in which i have the clientsname and their passwords stored.

Any help or samples would be appreciaeted
Your approach will work. You just need to check that oldpassword is correct and that the two new password fields are the same and comply to any rules you want about password length format etc and then store the new password in your password table.
 

JBurlison

Registered User.
Local time
Yesterday, 23:16
Joined
Mar 14, 2008
Messages
172
Here is an example of a password change VBA code in my eyes, i have not been doing this long so please correct me if im wrong.

Code:
Dim Currentpass As String 'This is the current password
Dim Newpass As String 'This is the new password

'At this point you should have 3 text boxes in your form 2 for new passwords (to confirm that they match and 1 to confirm the Old password. For this purpose we will name the text boxes Txt_old, Txt_newone, Txt_newtwo

CurrentPass = [Your Current password field here] 'Dlookup if necessary

If Currentpass = Txt_old Then

            Newpass = Txt_newone

                 If Newpass = Txt_newtwo
                            [Your Current password field here] = Newpass
                 Else
                   MsgBox "Your New Passwords Do Not Match"
                 End If
Else
MsgBox "Current password invalid, Please try again"
End If


Just my outtake on it as to what i have learned from VBA this past month. this could be wrong tho. like i said i am still new to VBA
 

Rabbie

Super Moderator
Local time
Today, 04:16
Joined
Jul 10, 2007
Messages
5,906
Here is an example of a password change VBA code in my eyes, i have not been doing this long so please correct me if im wrong.

Code:
Dim Currentpass As String 'This is the current password
Dim Newpass As String 'This is the new password

'At this point you should have 3 text boxes in your form 2 for new passwords (to confirm that they match and 1 to confirm the Old password. For this purpose we will name the text boxes Txt_old, Txt_newone, Txt_newtwo

CurrentPass = [Your Current password field here] 'Dlookup if necessary

If Currentpass = Txt_old Then

            Newpass = Txt_newone

                 If Newpass = Txt_newtwo
                            [Your Current password field here] = Newpass
                 Else
                   MsgBox "Your New Passwords Do Not Match"
                 End If
Else
MsgBox "Current password invalid, Please try again"
End If


Just my outtake on it as to what i have learned from VBA this past month. this could be wrong tho. like i said i am still new to VBA
This will work but you will need to add code to store Newpass in your password table. This will entail opening a recordset and finding the relevant user record and then updating the password field. Finally closing the record.
 

JBurlison

Registered User.
Local time
Yesterday, 23:16
Joined
Mar 14, 2008
Messages
172
Hummm... So could you post some sample code how that would be done?
 

KenHigg

Registered User
Local time
Yesterday, 23:16
Joined
Jun 9, 2004
Messages
13,327
Here's a piece I sliced out of one my apps...
 

Attachments

  • CustomSecurity.zip
    47.9 KB · Views: 114

goldstar19821982

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 17, 2008
Messages
78
Hi Rabbi

How u mentioned to set the recordset, have you got an example of how this could be done
 

goldstar19821982

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 17, 2008
Messages
78
Hello All,

This is what i have used, But it does seem to like it. It brings up a error on where i set the recordset.
Secondly is does not overwrite the current password in the table

Dim Currentpass As String 'This is the current password
Dim Newpass As String 'This is the new password
Dim rstchange As DAO.Recordset

Private Sub cmdOpen_Click()
Set rstchange = dbase.OpenRecordset("tbluser", dbOpenDynaset)
Currentpass = DLookup("[Password]", "tblClient", "[Name]='" & txtName.Value & "'") 'Dlookup if necessary

If Currentpass = txtoldpassword.Value Then

Newpass = txtnew

If Newpass = txtnew1 Then
txtoldpassword = Newpass
rstchange.Edit
rstchange("password") = txtnew.Value
rstchange.Update
Else
MsgBox "Your New Passwords Do Not Match"
End If
Else
MsgBox "Current password invalid, Please try again"
End If
 

goldstar19821982

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 17, 2008
Messages
78
Ken,

Jus been playing with the system you have put up. when the password is changed and submit is pressed it displays a message

Operation must use an updateable query

What is that referring to?
 

Rabbie

Super Moderator
Local time
Today, 04:16
Joined
Jul 10, 2007
Messages
5,906
Try the following

Code:
Dim Currentpass As String 'This is the current password
Dim Newpass As String 'This is the new password
Dim rstchange As DAO.Recordset
dim dbase as Database

Private Sub cmdOpen_Click()
set dbase = currentdb
Set rstchange = dbase.OpenRecordset("tbluser", dbOpenDynaset)
Currentpass = DLookup("[Password]", "tblClient", "[Name]='" & txtName.Value & "'") 'Dlookup if necessary

If Currentpass = txtoldpassword.Value Then

Newpass = txtnew

If Newpass = txtnew1 Then
txtoldpassword = Newpass
rstchange.Edit
rstchange("password") = txtnew.Value
rstchange.Update
Else
MsgBox "Your New Passwords Do Not Match"
End If
Else
MsgBox "Current password invalid, Please try again"
End If
Good luck
 

Rabbie

Super Moderator
Local time
Today, 04:16
Joined
Jul 10, 2007
Messages
5,906
Ken,

Jus been playing with the system you have put up. when the password is changed and submit is pressed it displays a message

Operation must use an updateable query

What is that referring to?
See this link for info on what makes a query updateable or not
 

goldstar19821982

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 17, 2008
Messages
78
its highlighting the dlookup and saying you have cancelled the previous operation any ideas?
 

KenHigg

Registered User
Local time
Yesterday, 23:16
Joined
Jun 9, 2004
Messages
13,327
Ken,

Jus been playing with the system you have put up. when the password is changed and submit is pressed it displays a message

Operation must use an updateable query

What is that referring to?


Do you have the users table open?
 

Rabbie

Super Moderator
Local time
Today, 04:16
Joined
Jul 10, 2007
Messages
5,906
Problem is you are not finding the right record in the user table when you update.

Try this
Code:
Dim Currentpass As String 'This is the current password
Dim Newpass As String 'This is the new password
Dim rstchange As DAO.Recordset
dim dbase as Database

Private Sub cmdOpen_Click()
set dbase = currentdb
Set rstchange = dbase.OpenRecordset("tblclient", dbOpenDynaset)
rstchange.findnext("[Name]='txtName.value'"
Currentpass = rstchange.Password
If Currentpass = txtoldpassword.Value Then

Newpass = txtnew

If Newpass = txtnew1 Then
txtoldpassword = Newpass
rstchange.Edit
rstchange.password = txtnew.Value
rstchange.Update
Else
MsgBox "Your New Passwords Do Not Match"
End If
Else
MsgBox "Current password invalid, Please try again"
End If
rstchange.close

End Sub

You may need to change table and field names to match what you actually have in your DB
 

Users who are viewing this thread

Top Bottom