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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open database with password, then run a macro

Status
Not open for further replies.

Molby

Technical User
May 15, 2003
520
GB
I'm currently using the following code to open an access database, and then run a macro. I now want to apply a database password, but still have Excel open the database. Any ideas on how this can be done? I've checked and the OpenCurrentDatabase doesn't seem to have a password option.
Code:
Sub opendatabase()
DatabaseName$ = "C:\Test.mdb"
Set acApp = CreateObject("Access.Application")
acApp.Visible = True
acApp.OpenCurrentDatabase (DatabaseName$)
acApp.DoCmd.RunMacro "Mac-MacroName"
End Sub
 
erm - straight from VBA help:

expression.OpenCurrentDatabase(filepath, Exclusive, bstrPassword)

expression Required. An expression that returns one of the objects in the Applies To list.

filepath Required String. A string expression that is the name of an existing database file, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form: \\Server\Share\Folder\Filename

Note If you don't supply the filename extension, .mdb is appended to the filename.

Exclusive Optional Boolean. Specifies whether you want to open the database in exclusive mode. The default value is False, which specifies that the database should be opened in shared mode.

bstrPassword Optional String. The password to open the specified database.



Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Geoff,

What version of Access is that, because it's not there in 2000....
Syntax
application.OpenCurrentDatabase dbname[, exclusive]
The OpenCurrentDatabase method has the following arguments.
application The Application object.
dbname A string expression that is the name of an existing database file, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form:
\\Server\Share\Folder\Filename
Note If you don't supply the filename extension, .mdb is appended to the filename.
exclusive Optional. A Boolean value that specifies whether you want to open the database in exclusive mode. The default value is False, which specifies that the database should be opened in shared mode.
 
aaaaah - version issues - that was from XP :-( apologies

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
No problem, I take it there's no easy way round this then?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top