>

NewPassword Method

Applies To

Database Object, User Object.

Description

Changes the password of an existing user account or Jet version 3.0 database.

Syntax

object.NewPassword oldpassword, newpassword

The NewPassword method syntax has these parts.

Part

Description

object

A variable of an object data type that represents the User object or a Jet 3.0 Database object whose Password property you want to change.

oldpassword

A string expression that is the current setting of the Password property of the User or Jet 3.0 Database object.

newpassword

A string expression that is the new setting of the Password property of the User or Jet 3.0 Database object.


Remarks

The oldpassword and newpassword strings can be up to 14 characters long and can include any characters except the ASCII character 0 (null). To clear the password, use a zero-length string ("") for newpassword.

Passwords are case-sensitive.

If object refers to a User object that is not an element of a Users collection, an error occurs. To set a new password, you must either be logged on as the user whose user account you're changing, or you must be a member of the Admins group. The Password property of a User object is write-only — users can't read the current value.

If object refers to a Jet version 3.0 Database object, this method offers a limited form of security in the form of password protection. When creating or opening a version 3.0 .mdb file, part of the Connect string describes the password; thus, no work is required of your DAO code.

If a database has no password, one will be created automatically by passing "" for the old password. If you lose your password, you can never open the database again.

See Also

Name Property, PID Property.

Example

This example changes the password of the existing user Pat Smith from My Secret to msMSApw. The user must be logged on as Pat Smith or as a member of the Admins group.


Workspaces(0).Users("Pat Smith").NewPassword "My Secret", "msMSApw"