Microsoft KB Archive/192028

= ACC: "Run-Time Error '3031': Not a Valid Password" Error Message =

Article ID: 192028

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q192028



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you try to open a database programmatically, you may receive the following error message, even though the password is correct:

Run-time error '3031':

Not a valid password.



CAUSE
When you manually set the database password to a password with fourteen characters (the limit), you cannot use that same password to programmatically open the database.



Method 1
Do not select a password that is longer than 13 characters if you need to open the database programmatically.

Method 2
When you open the database programmatically, you need only include the first 13 characters of the database password.

To make the example in the "Steps to Reproduce Problem" section work, change the following line of code   Set db = ws.OpenDatabase _

("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _    False, False, "MS Access;PWD=FourteenCharac") to read as follows:   Set db = ws.OpenDatabase _

("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _    False, False, "MS Access;PWD=FourteenChara") NOTE: This will programmatically open the Northwind.mdb database even though the password is not correct.



STATUS
Microsoft has confirmed this to be a problem in the products listed at the beginning of this article.



Steps to Reproduce Problem
 Open the sample database Northwind.mdb exclusively. On the Tools menu, point to Security, and then click Set Database Password. Type FourteenCharac in the Password and Verify boxes. Close Northwind.mdb.</li> Create and open a new database named Test.mdb.</li>  In the Database window, Click Modules. Click New, and then type the following code: Sub OpenDB

Dim db As Database Dim ws As Workspace

Set ws = DBEngine.Workspaces(0)

' The default path to Northwind.mdb in Access version 7.0 is   ' C:\MSOffice\Access\Samples\Northwind.mdb Set db = ws.OpenDatabase _ ("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _      False, False, "MS Access;PWD=FourteenCharac")

Set ws = Nothing Set db = Nothing

End Sub </li> On the View menu, click Debug Window. Type OpenDB, and then press ENTER.</li></ol>

Note that you receive the error message mentioned in the "Symptoms" section.

Steps to Remove the Password from Northwind.mdb

 * 1) Open the sample database Northwind.mdb exclusively.
 * 2) Type FourteenCharac in the Enter Database Password box. Click OK
 * 3) On the Tools menu, point to Security, and then click Unset Database Password.
 * 4) Type FourteenCharac in the Password box. Click OK
 * 5) Close the Northwind.mdb database.

Additional query words: wrong invalid incorrect run time error 3031

Keywords: kbbug kbpending KB192028

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.