Database Password - Command Line Switch

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

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,
 
On Fri, 18 Dec 2009 19:55:01 -0800, Steven

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 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:Database 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
 
On Sat, 19 Dec 2009 10:13:01 -0800, Steven

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
 
Tom,

Thank you for the quick replies. So, I didn't do exactly what you said but
it is not getting past the pop-up for the password.

I'm running a non secured database code that would open the other DB that
has a database password. In that db password protected database is an
autoexec macro that runs a module. In that module it looks for a /cmd "auto"
piece that would auto print a report and close the database.

Here is what I have in the unsecured db:

Public Function ITProjectReportTest()
ITProjectReport
End Function

Public Function ITProjectReport()
Const DB_TO_OPEN As String = "l:\access\databases\IT Dept Inventory.mdb"
Const DB_PASSWORD As String = "Password" ' replaced for this purpose
Dim objAccess As Access.Application
Set objAccess = New Access.Application
objAccess.OpenCurrentDatabase DB_TO_OPEN, False, MY_PASSWORD
End Function

I run the test module and it pops up the Enter Password box.

Thank you again for all your help....I see light at the end of the tunnel.
I would love to explore this option but if this is getting too much - I can
link the tables and copy the report over to the unsecured db :(
 
On Sat, 19 Dec 2009 12:59:01 -0800, Steven

You probably do not have OPTION EXPLICIT at the top of your code
module. This option is CRITICAL for programmers and it's too bad MSFT
doesn't see it that way. Please also turn on this option in Tools >
Options.
Once in place, select Debug > Compile, and it will become obvious why
your version does not work (hint: DB_PASSWORD <> MY_PASSWORD).

-Tom.
Microsoft Access MVP
 
Tom,

Thank you again for your help.

I did not have option explicit on nor was 'Require Variable Declaration'
checked in the Tools - Options section; they are now AND it worked. Thank
you.

Perhaps you know the answer to my next part. Can you also pass a /cmd
variable through this process?

Steven
 
On Mon, 21 Dec 2009 08:05:01 -0800, Steven

I don't think so, but here is an elegant solution: after the
OpenCurrentDatabase call, write:
objAccess.DoCmd.RunMacro "myMacro"

-Tom.
Microsoft Access MVP
 
Tom,

Thank you for your help. I ended up placing the code below to have it auto
function based on the time I scheduled the auto printout:
If Time < CDate("06:00") Then
result = AutoProcess()
Exit Function
End If

You were very helful.

Have a great holiday,
Steven
 
Back
Top