programatically changing your Access password

B

Brad Pears

What are the calls to implement into an Access 2000 app that would allow me
as the programmer to give the user a form where they can set/change their
password instead of using the "Access Security and GRoups" area? I have
removed all of the Access built in menus etc... and therefore need to give
the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
 
B

Brad Pears

Thanks a lot for that! That is exactly what I was looking for!!!

Brad
Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones
are identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Brad Pears said:
What are the calls to implement into an Access 2000 app that would allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area? I
have removed all of the Access built in menus etc... and therefore need
to give the user the ability to do this themselves... I only want them
to set/change their own password. I dpo not want them scrolling through
the list of users and groups etc...

Thanks,

Brad
 
P

pcc DaveF

Does anyone know why I would get an error 3033 "You do not have privileges
for object <username>" when I try to change the password of a user I've
logged in as? Is there some strange permission associated with a user object
I need to set?

Thanks very much -

Dave

Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Brad Pears said:
What are the calls to implement into an Access 2000 app that would allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area? I
have removed all of the Access built in menus etc... and therefore need to
give the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Hi Dave

That is the error you get if the old password you supply is incorrect.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

pcc DaveF said:
Does anyone know why I would get an error 3033 "You do not have privileges
for object <username>" when I try to change the password of a user I've
logged in as? Is there some strange permission associated with a user
object
I need to set?

Thanks very much -

Dave

Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Brad Pears said:
What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area?
I
have removed all of the Access built in menus etc... and therefore need
to
give the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
P

pcc DaveF

AHA! I was wondering how to trap for that as well.. nothing like 2 answers in
1 response.

Thanks much!

Dave

Graham Mandeno said:
Hi Dave

That is the error you get if the old password you supply is incorrect.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

pcc DaveF said:
Does anyone know why I would get an error 3033 "You do not have privileges
for object <username>" when I try to change the password of a user I've
logged in as? Is there some strange permission associated with a user
object
I need to set?

Thanks very much -

Dave

Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area?
I
have removed all of the Access built in menus etc... and therefore need
to
give the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Sam said:
Hello Graham

How would a newbie set this up???

Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Brad Pears said:
What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area?
I
have removed all of the Access built in menus etc... and therefore need
to
give the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
S

Sam

graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

Graham Mandeno said:
Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Sam said:
Hello Graham

How would a newbie set this up???

Graham Mandeno said:
Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the old
password and the new one (twice, to verify) and checks the two new ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can set/change
their password instead of using the "Access Security and GRoups" area?
I
have removed all of the Access built in menus etc... and therefore need
to
give the user the ability to do this themselves... I only want them to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

The three textboxes should be unbound. In other words, their ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

Graham Mandeno said:
Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Sam said:
Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the
old
password and the new one (twice, to verify) and checks the two new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and GRoups"
area?
I
have removed all of the Access built in menus etc... and therefore
need
to
give the user the ability to do this themselves... I only want them
to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
S

Sam

Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as when I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

Graham Mandeno said:
The three textboxes should be unbound. In other words, their ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

Graham Mandeno said:
Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for the
old
password and the new one (twice, to verify) and checks the two new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and GRoups"
area?
I
have removed all of the Access built in menus etc... and therefore
need
to
give the user the ability to do this themselves... I only want them
to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Hi Sam

What is the error? Does it occur only when you have entered the old
password incorrectly?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as when
I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

Graham Mandeno said:
The three textboxes should be unbound. In other words, their
ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

:

Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask
property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case
sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword
strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for
the
old
password and the new one (twice, to verify) and checks the two new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then
the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that
would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and GRoups"
area?
I
have removed all of the Access built in menus etc... and
therefore
need
to
give the user the ability to do this themselves... I only want
them
to
set/change their own password. I dpo not want them scrolling
through
the
list of users and groups etc...

Thanks,

Brad
 
S

Sam

Graham

I gat a Visual Basic Error "Compile Error. Method or Data Member Not Found"

The VB Editor highlights the SetFocus command (as part of the
txtOldPwd.SetFocus)

The same error occurs regardless if you enter an old password and new or if
you leave all of the password fields blank.

I did add an additional field which records the username of the person
trying to change their password... Could this be causing the problem???

Graham Mandeno said:
Hi Sam

What is the error? Does it occur only when you have entered the old
password incorrectly?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as when
I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

Graham Mandeno said:
The three textboxes should be unbound. In other words, their
ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

:

Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask
property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case
sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword
strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks for
the
old
password and the new one (twice, to verify) and checks the two new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox then
the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that
would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and GRoups"
area?
I
have removed all of the Access built in menus etc... and
therefore
need
to
give the user the ability to do this themselves... I only want
them
to
set/change their own password. I dpo not want them scrolling
through
the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Hi Sam

Are you sure the NAME of the textbox where you enter the old password is
"txtOldPwd"?

Make sure you have
Option Explicit
at the top of your module (and EVERY module) unless you want to waste hours
chasing problems with mis-names variables.

You should always make sure all your code compiles by clicking
Debug>Compile {projectname}. Compiler errors which are not discovered until
runtime can be a real hassle!

The extra textbox is a good idea. Set its properties as follows:
ControlSource: ="Change password for " & CurrentUser()
Enabled: No
Locked: Yes

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham

I gat a Visual Basic Error "Compile Error. Method or Data Member Not
Found"

The VB Editor highlights the SetFocus command (as part of the
txtOldPwd.SetFocus)

The same error occurs regardless if you enter an old password and new or
if
you leave all of the password fields blank.

I did add an additional field which records the username of the person
trying to change their password... Could this be causing the problem???

Graham Mandeno said:
Hi Sam

What is the error? Does it occur only when you have entered the old
password incorrectly?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the
following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as
when
I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

:

The three textboxes should be unbound. In other words, their
ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

:

Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask
property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them
appropriate
captions. Paste the following code into your form's module. Note
the
Option Compare Binary is important because passwords are case
sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before
clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the
Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword
strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks
for
the
old
password and the new one (twice, to verify) and checks the two
new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox
then
the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that
would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and
GRoups"
area?
I
have removed all of the Access built in menus etc... and
therefore
need
to
give the user the ability to do this themselves... I only
want
them
to
set/change their own password. I dpo not want them scrolling
through
the
list of users and groups etc...

Thanks,

Brad
 
S

Sam

Graham

I feel like an idiot!! I forgot to add the txtOldPwd to the taxt box.

it is working just fine now... Thanks for your help

Graham Mandeno said:
Hi Sam

Are you sure the NAME of the textbox where you enter the old password is
"txtOldPwd"?

Make sure you have
Option Explicit
at the top of your module (and EVERY module) unless you want to waste hours
chasing problems with mis-names variables.

You should always make sure all your code compiles by clicking
Debug>Compile {projectname}. Compiler errors which are not discovered until
runtime can be a real hassle!

The extra textbox is a good idea. Set its properties as follows:
ControlSource: ="Change password for " & CurrentUser()
Enabled: No
Locked: Yes

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham

I gat a Visual Basic Error "Compile Error. Method or Data Member Not
Found"

The VB Editor highlights the SetFocus command (as part of the
txtOldPwd.SetFocus)

The same error occurs regardless if you enter an old password and new or
if
you leave all of the password fields blank.

I did add an additional field which records the username of the person
trying to change their password... Could this be causing the problem???

Graham Mandeno said:
Hi Sam

What is the error? Does it occur only when you have entered the old
password incorrectly?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the
following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as
when
I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

:

The three textboxes should be unbound. In other words, their
ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field 'txtOldPwd'

What have I done wrong?????

:

Hi Sam

Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask
property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them
appropriate
captions. Paste the following code into your form's module. Note
the
Option Compare Binary is important because passwords are case
sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before
clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the
Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword
strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks
for
the
old
password and the new one (twice, to verify) and checks the two
new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox
then
the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app that
would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and
GRoups"
area?
I
have removed all of the Access built in menus etc... and
therefore
need
to
give the user the ability to do this themselves... I only
want
them
to
set/change their own password. I dpo not want them scrolling
through
the
list of users and groups etc...

Thanks,

Brad
 
G

Graham Mandeno

Glad you got it working, Sam.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham

I feel like an idiot!! I forgot to add the txtOldPwd to the taxt box.

it is working just fine now... Thanks for your help

Graham Mandeno said:
Hi Sam

Are you sure the NAME of the textbox where you enter the old password is
"txtOldPwd"?

Make sure you have
Option Explicit
at the top of your module (and EVERY module) unless you want to waste
hours
chasing problems with mis-names variables.

You should always make sure all your code compiles by clicking
Debug>Compile {projectname}. Compiler errors which are not discovered
until
runtime can be a real hassle!

The extra textbox is a good idea. Set its properties as follows:
ControlSource: ="Change password for " & CurrentUser()
Enabled: No
Locked: Yes

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sam said:
Graham

I gat a Visual Basic Error "Compile Error. Method or Data Member Not
Found"

The VB Editor highlights the SetFocus command (as part of the
txtOldPwd.SetFocus)

The same error occurs regardless if you enter an old password and new
or
if
you leave all of the password fields blank.

I did add an additional field which records the username of the person
trying to change their password... Could this be causing the problem???

:

Hi Sam

What is the error? Does it occur only when you have entered the old
password incorrectly?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Graham. Thanks The fields are now working ok.

I am now getting an error with the code. In particular with the
following
snippet:-

Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & "The old password you entered was
incorrect|" & "Please enter the correct password"

There seems to be a problem with the "txtOldPwd.SetFocus" command as
when
I
click on the "OK" Button, the code debugger highlights this section.

Everything else appears to be working ok.

:

The three textboxes should be unbound. In other words, their
ControlSource
properties should be blank.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

graham

I get an error message when trying to type in a password:-

'Control Cant be edited. it is bound to an unknown field
'txtOldPwd'

What have I done wrong?????

:

Hi Sam

Make a form with three textboxes and two command buttons. Name
the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask
property
for eack to Password.

Name the command buttons cmdCancel and cmdOK. Give them
appropriate
captions. Paste the following code into your form's module.
Note
the
Option Compare Binary is important because passwords are case
sensitive.

Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before
clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the
Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error
Changing
Password"
Resume ProcEnd
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello Graham

How would a newbie set this up???

:

Hi Brad

All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword
strOldPwd,
strNewPwd

Of course, you will need to wrap this up in a form which asks
for
the
old
password and the new one (twice, to verify) and checks the
two
new
ones
are
identical.

BTW, if you specify "Password" as the InputMask on a textbox
then
the
characters typed will be displayed as ****.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

What are the calls to implement into an Access 2000 app
that
would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and
GRoups"
area?
I
have removed all of the Access built in menus etc... and
therefore
need
to
give the user the ability to do this themselves... I only
want
them
to
set/change their own password. I dpo not want them
scrolling
through
the
list of users and groups etc...

Thanks,

Brad
 
Top