Password Chg Event That Works (Short One)

C

Casey

Hi,

This is sort of a repost, but I have some code below
that is almost doing the job for me as an event assigned
to the onclick property of a button on a form.

I am attempting to have this code below change a
users password. It presents a small input box to the user
to place the new password in, after the entry is accepted
by the box the code next changes the password to the entry
that the user made in that input box.

The code goes as far as opening the box, and
accepting the entry into the input box, but after that I
get an error message.

Does anyone have any idea on what could be missing or
wrong?

Please don't recommend any long drawn out code
samples that I should try, what I want is plain and simple.

If you have an event that you have used to just
accept the entry from a user, and have the password
changed to that entry, I would be interested.

That is all that I want is to have a short procedure
that changes the password per an entry by a user, nothing
more. If someone out there has a real example that really
works, or if you have a correction to the code that I have
in this message that would make it useful, let me know.

As I mentioned before, what is below almost works,
but stops after the user entry acceptance, and the
password is not changed. Is there something that I am not
setting or declaring?

Private Sub Command174F_Click()
Dim wrkDefault As Workspace
Dim usrNew As User
Dim grpNew As Group
Dim grpMember As Group
Dim strPassword As String
Set wrkDefault = DBEngine.Workspaces(0)
With wrkDefault
Set usrNew = CurrentUser()
strPassword = InputBox("Enter new password:")
usrNew.NewPassword "Password1", strPassword
MsgBox "Password changed!"
End With
End Sub

Please don't email me any ineffective samples.

I don't want to sound picky, I just want some real,
knowledgeable advice on how to do a simple password change
in a real effective fully coded event.

If you can help, I would really appreciate it.

Thanks for any real advice ahead of time.

Casey
 
D

Douglas J. Steele

CurrentUser doesn't return a User object: it simply returns the name of the
user.

With wrkDefault
Set usrNew = .Users(CurrentUser())
strPassword = InputBox("Enter new password:")
usrNew.NewPassword "Password1", strPassword
MsgBox "Password changed!"
End With

BTW, you really should read the "Asking questions the right way" section at
http://www.mvps.org/access/netiquette.htm
 
C

Casey

Hi Doug,

The code that you expressed I am assuming can replace
the With statement I was using. If so, I appreciate it
very much. Thank you for expert advice.

Have a nice evening.

Casey
 

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