Part | Description |
object | An object variable that represents the User object or a Microsoft Jet 3.x Database object whose Password property you want to change. |
oldpassword | A String that is the current setting of the Password property of the User or Jet 3.x Database object. |
newpassword | A String that is the new setting of the Password property of the User or Jet 3.x Database object. |
Sub NewPasswordX()
Dim wrkDefault As Workspace
Dim usrNew As User
Dim grpNew As Group
Dim grpMember As Group
Dim strPassword As String
' Get default workspace.
Set wrkDefault = DBEngine.Workspaces(0)
With wrkDefault
' Create and append new user.
Set usrNew = .CreateUser("Pat Smith", _
"abc123DEF456", "Password1")
.Users.Append usrNew
' Create and append new group.
Set grpNew = .CreateGroup("Accounting", _
"UVW987xyz654")
.Groups.Append grpNew
' Make the new user a member of the new group.
Set grpMember = usrNew.CreateGroup("Accounting")
usrNew.Groups.Append grpMember
' Ask user for new password. If input is too long, ask
' again.
Do While True
strPassword = InputBox("Enter new password:")
Select Case Len(strPassword)
Case 1 To 14
usrNew.NewPassword "Password1", strPassword
MsgBox "Password changed!"
Exit Do
Case Is > 14
MsgBox "Password too long!"
Case 0
Exit Do
End Select
Loop
' Delete new User and Group objects because this
' is only a demonstration.
.Users.Delete "Pat Smith"
.Groups.Delete "Accounting"
End With
End Sub