On Sat, 19 Dec 2009 10:13:01 -0800, Steven
<(E-Mail Removed)> wrote:
I played around with OpenDatabase a bit more, and although you can
open a DatabasePassword-protected database with it, that database does
not run its AutoExec macro, which I'm sure is important to you.
So we move on to OpenCurrentDatabase:
Create an unsecured database with an AutoExec macro with one line:
Action=RunCode, FunctionName=InitApplication()
Create a standard module and paste in this code:
'This function is called by AutoExec macro.
Public Function InitApplication()
Const DB_TO_OPEN As String =
"c:\temp\myTestDatabaseWithDbPassword.accdb"
Const DB_PASSWORD As String = "myPassword"
Dim objAccess As Access.Application
Set objAccess = New Access.Application
objAccess.OpenCurrentDatabase DB_TO_OPEN, False, MY_PASSWORD
End Function
Replace myConstants with yours. Close and reopen this db. Observe that
it opens the secured db and runs its autoexec macro.
-Tom.
Microsoft Access MVP
>I am confused, obviously.
>
>I also don't know how to use the information you provided.
>
>With database password
>This is the connection string to use when you have an access database
>protected with a password using the Set Database Password function in
>Access.Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet
>OLEDB
atabase Password=MyDbPassword;
>
>Just copying the access.provider=...into code gives me an error and I don't
>know how to call the function.
>
>Any help would be greatly appreciated.
>
>Thank you,
>
>Steven
>
>"Tom van Stiphout" wrote:
>
>> On Fri, 18 Dec 2009 19:55:01 -0800, Steven
>> <(E-Mail Removed)> wrote:
>>
>> You are confusing Workgroup security (which requires a username and
>> password, and uses the /user, /pwd command line switches) with the
>> Database Password (which requires only a password, and for which there
>> is no command line switch).
>>
>> If you REALLY want to do this, you may want to launch an unsecured
>> Access app which uses the OpenDatabase method to open your
>> password-secured app. The connect string can then contain the
>> password. See http://www.connectionstrings.com/access for details.
>>
>> -Tom.
>> Microsoft Access MVP
>>
>>
>>
>> >I have a database with a database level password. I want to open the
>> >database using 'Scheduled Tasks' and pass the password. I have used the /pwd
>> >link and a /User of "Admin" but it is not working. What is the user if I'm
>> >using a database password? is there a way to do this?
>> >
>> >I've searched through hundreds of password questions and can't seem to find
>> >it. Any help would be greatly appreciated.
>> >
>> >Thank you,
>> .
>>