Good day!

I have an Access 97 database which I password-protected. How can I open it in my VB code? I have below my code.

Dim db as Database
Dim dbPswd as string

On Error GoTo ShowErr

dbPswd = "myPswd" ' sample only
Set db = OpenDatabase(App.Path & "\dbf\myDB.mdb", , , ";pwd=" & dbPswd)
.......
.......

ShowErr:
Msgbox Err.Number ": " & Err.Description

I set my password in Access to be "myPswd". When I run my code, as soon as I reach the OpenDatabase statement, I get Error No. 3031 "Not a valid password". What's wrong with my code? If the database is successfully opened with the password, will the database be opened exclusively? Thanks in advance!