New Password

I

Irwin109

(Didn't seem to come up last time I posted so if it has appeared twice
apologies for the double post)

MS Access 2003
Windows XP

I finally got my 0.4beta out to the Front End users and it seems to be going
down without a hitch, touch wood! (Thanks to all who helped me with the
mountain of errors I got whilst creating and distributing the database.)

This time I'm just wondering if there is anyway (probably coding if it is
possible) to prompt and give the ability for users to change thier password
every month OR create a new password if their current password is blank.
Thanks for any help in advance.
 
I

Irwin109

....I meant I have already set up the user accounts, but no passwords. I was
just wondering if there was a way to prompt them so I don't have to go round
individuals and make them choose a password (as everyone requires a password
for data security once the Alpha is issued).
 
I

Irwin109

I was wanting them to be able to choose their own. But I guess that will not
be possible then?
 
I

Irwin109

Can they do this without going into the Tools>Security>User Group Accounts
menu?
(Most of my Front End Users have little to no experience with access) I was
hoping to create a pop-up
 
I

Irwin109

"whatever you provide for them." is what I'm after, i.e either some sample
code or an idea of what to put on a form.
 
N

NevilleT

Hi Irwin

Create a form with three text boxes (OldPass, NewPass, ConfirmPass) and 2
buttons (CancelButton, ChangeButton) You can also create another textbox to
display the current user. Call it UserName and set the control source to
=[Currentuser]

Paste the following code

Option Compare Database
Option Explicit


Private Sub CancelButton_Click()
DoCmd.Close
End Sub

Private Sub ChangeButton_Click()
Dim strOld As String
Dim strNew As String
Dim strConfirm As String
Dim strUser As User

On Error GoTo cmdChange_Err

If IsNull(Me!OldPass) Then
strOld = ""
Else
strOld = Me!OldPass
End If

If IsNull(Me!NewPass) Then
strNew = ""
Else
strNew = Me!NewPass
End If

If IsNull(Me!ConfirmPass) Then
strConfirm = ""
Else
strConfirm = Me!ConfirmPass
End If

If strNew <> strConfirm Then
MsgBox "The passwords are different. Please enter again.",
vbCritical
Me!NewPass = ""
Me!ConfirmPass = ""
Me!NewPass.SetFocus
Else
If IsNull(Me!OldPass) Then
MsgBox "Leaving the old password empty will cause an error
unless " & _
"you currently have no password.", vbOKOnly
End If

Call ChangeUserPassword(CurrentUser(), strOld, strNew)
End If

Exit Sub

cmdChange_Err:
MsgBox Err.Description
End Sub

Private Sub ChangeUserPassword(strUserName As String, strOldPassword As
String, _
strNewPassword As String)
On Error GoTo ChangeUserPassword_Err:

DBEngine(0).Users(strUserName).NewPassword strOldPassword, strNewPassword
MsgBox "Password change successful.", vbInformation
DoCmd.Close
Exit Sub

ChangeUserPassword_Err:
MsgBox Err.Description
End Sub

Private Sub ConfirmPass_BeforeUpdate(Cancel As Integer)
If Len(Me!ConfirmPass) > 14 Then
MsgBox "Password is limited to 14 characters", vbCritical
End If
End Sub

Private Sub NewPass_BeforeUpdate(Cancel As Integer)
If Len(Me!NewPass) > 14 Then
MsgBox "Password is limited to 14 characters", vbCritical
End If
End Sub
 

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