Want to create a reset password button on a form

G

Guest

I've got a form that only my managers have access to (suposedly). The form
displays a record for each of our guys in our department. Each of our guys
can login and update their own record using another form with limited
capabilities. I want my managers to click a button that will reset the
password back to the default password (date of birth) for the guys record of
whom he's looking at. Here's my code:

Dim intReponse as integer

intResponse = MsgBox("Are you sure you wish to reset this FSR's password?",
vbYesNo, "Reset Password?")

If intResponse = vbYes Then
If sResetPassword(Me.Username, Me.DOB) = True Then
MsgBox "FSR's password has been reset to the default.",
vbOKOnly, "Reset Password"
Else
MsgBox "Unable to reset password. " & Err.Number & ": " &
Err.Description
End If
Else
MsgBox "Action has been canceled", vbInformation, "Cancel Changes"
Exit Sub
End If
___________________________________________________________________
Public Function sResetPassword(ByVal strUser As String, Optional varPwd As
Variant) As Integer

On Error GoTo Err_Golldarnit

Dim ws As Workspace
Set ws = DBEngine.Workspaces(0)
ws.Users.Refresh
ws.Groups("users").Users(strUser).NewPassword varPwd
sResetPassword = True

Err_Golldarnit:
MsgBox "Something went wrong" & Err.Description
Exit Sub
____________________________________________________________________

Access seems to be getting stuck on this string:
ws.Groups("users").Users(strUser).NewPassword varPwd

When I try to Compile it highlights the .NewPassword part and says, "Compile
Error. Argument not Optional"
 
G

Guest

I've learned that the .NewPassword function requires the old password and the
new password arguments. But I want my administrators to just
administratively reset the password without having to know what the old
password is. Anyone know how to do this?
 
G

Granny Spitz via AccessMonster.com

Jonathan said:
I've learned that the .NewPassword function requires the old password and the
new password arguments. But I want my administrators to just
administratively reset the password without having to know what the old
password is.

The owner of the database and members of the admins group can reset other
users' passwords by using an empty string for the old password. And it's not
a good idea to use birthdays as passwords because that's one of the first
things hackers check. Pick something that's not so easily guessed.
 
G

Guest

Granny,

So what you're saying is I can use this line of code:

ws.Groups("users").Users(strUser).NewPassword "", varPwd

Assuming of course the person that's logged in is an administrator or owner
of the database?

I'll use something stronger for their default password.
 
G

Guest

Granny,

I used it and it worked like a charm. By the way, I do actually use
something stronger than the DOB for their default password. I just didn't
want to say what it is and figured DOB would be good enough for the example.

But you're great for answering that question for me. I made the same post
on utteraccess.com and nobody seemed to know how to fix it.

thanks again,
Jonathan
 
G

Granny Spitz via AccessMonster.com

Jonathan said:
So what you're saying is I can use this line of code:

ws.Groups("users").Users(strUser).NewPassword "", varPwd

Each user name is unique so you don't need to identify the group. You can
use the Users collection like this:

Dim ws As Workspace
Dim usr As User

Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUser)
usr.NewPassword "", strPwd
Assuming of course the person that's logged in is an administrator or owner
of the database?

Yes.
 
G

Granny Spitz via AccessMonster.com

Jonathan said:
I used it and it worked like a charm. By the way, I do actually use
something stronger than the DOB for their default password. I just didn't
want to say what it is and figured DOB would be good enough for the example.

You're welcome. I'm pleased it worked for you and you're wise not to show
all the cards in your hand.
But you're great for answering that question for me. I made the same post
on utteraccess.com and nobody seemed to know how to fix it.

Subliminal messages can be very effective. Your name backwards, FrickenStud,
might have intimidated them dear. <g>

http://www.utteraccess.com/forums/s...re=&Zu=&Zd=g&Zn=&Zt=7&Zs=a&Zy=#Post1281424&Zp
=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top