|
-
August 8th, 2000, 09:46 PM
#1
Opening a pasword-protected database
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!
-
August 9th, 2000, 01:05 AM
#2
Re: Opening a pasword-protected database
Hi !
You have to set parameter FALSE for Options and ReadOnly. Try like that.
Dim db as Database
Dim dbPswd as string
On Error GoTo ShowErr
dbPswd = "myPswd" ' sample only
Set db = OpenDatabase(App.Path & "\dbf\myDB.mdb", FALSE , FALSE , ";pwd=" & dbPswd)
.......
.......
ShowErr:
Msgbox Err.Number ": " & Err.Description
Let me know if it works.
-
August 9th, 2000, 02:59 AM
#3
Re: Opening a pasword-protected database
Thanks for the reply. Your suggestion worked! If I replace the second False parameter w/ True, does this mean that the database is exclusively opened until a db.Close statement is reached? What if it is one of the tables that I want to exclusively open?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|