PRB: Cannot Connect Data Control to a Password-Protected Access Database (306429)
The information in this article applies to:
- Microsoft Access 2000
- Microsoft Access 2002
- Microsoft Visual Basic Professional Edition for Windows 6.0
This article was previously published under Q306429 SYMPTOMS
If you attempt to use the Data control to connect to a password-protected Access database at design time, you receive the following error message:
Not a valid password
Specifically, this error occurs when you set the RecordSource property of the Data control.
RESOLUTION
To use the Data control with a password-protected Access 2000 or later database, you must set the Recordset property of the data control at run time as follows:
- In your project, click References from the Project menu, and then select the Microsoft DAO 3.6 Object Library check box.
- In the Form_Load event of your form that contains the Data control, place the following code where "Data1" is the name of your Data control. Make sure to change the path, table name, and password in the following code to reference your database.
Private Sub Form_Load()
Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim rst As DAO.Recordset
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase _
("C:\Atest.mdb", _
False, False, "MS Access;PWD=aaa")
Set rst = db.OpenRecordset("Table1", dbOpenDynaset)
Set Data1.Recordset = rst
End Sub
STATUS
This behavior is by design.
REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
238401 PRB: Error "Unrecognized Database Format" When You Upgrade to Access 2000 or 2002
Modification Type: | Minor | Last Reviewed: | 7/16/2004 |
---|
Keywords: | kbprb KB306429 |
---|
|