• Status: Solved
• Priority: Medium
• Security: Public
• Views: 3203

# how can i open with vba on microsoft access a database that is protected with a password

hi

i have this code to open a non-protected database
Dim accapp As Access.Application

Set accapp = New Access.Application

accapp.OpenCurrentDatabase d("c:\database\mydatabase.mdb")
accapp.Visible = True


what i have to add to this code to open a database that protected with a password?

thanks
0
bill201
4 Solutions

ConsultantCommented:
Some sample code illustrating how to do this:

http://msdn.microsoft.com/en-us/library/ms808201.aspx

Additional help constructing connection strings can be found at:

http://www.connectionstrings.com/

Kevin
0

Commented:
0

Commented:
Another option, authenticating yourself first then carrying on with your code as normal.

http://support.microsoft.com/kb/235422
0

Commented:
With the OpenCurrentDatabase command:

Dim accapp As Access.Application
dim strPwd as string

Set accapp = New Access.Application

accapp.OpenCurrentDatabase ("c:\database\mydatabase.mdb",, strPwd)
accapp.Visible = True

0

Author Commented:
thanks a lot for  your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.