Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Access Macro on PWD protected DB

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
US
I'm having trouble running an Access macro on a password protected Access database. If I remove the password and use the following code everything works fine.

Dim ac As Access.Application
Set ac = New Access.Application

ac.OpenCurrentDatabase ".mdb", False
ac.Visible = False
ac.DoCmd.RunMacro "macroname"
ac.CloseCurrentdB

Set ac = Nothing

However, with the password enabled it won't run automatically. You need to type in the password manually.

I've tried using the OLEDB to access the database and provide a password:

Dim conn
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=.mdb; "
conn.Properties("Jet OLEDB:Database Password") = "pswd"
conn.Open conn.ConnectionString

This opens the database, but it expects SQL strings to fill in the information. I just want to call a macro. Can this be done on a pswd protected dB? Any help would be appreciated. Thanks in advance.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top