By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,790 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,790 IT Pros & Developers. It's quick & easy.

Database password as parameter

P: n/a
Hallo all,

I have two dbs and I would like to open one db from another by calling a VBA
function. The db I'll try to invoke has a password.
What is my mistake ??

Option 1:

Function Open1()
Dim db As Database

On Error GoTo FehlerMeldung

erg = DBEngine.Workspaces(0).OpenDatabase("C:\Test\PWDDa ten.mdb", False,
False, ";PWD=secure")

FehlerMeldung:
MsgBox "Anmeldung fehlgeschlagen ", 16, "FEHLER !"

End Function

Option 2:
Function Open2()
Dim db As Database
Dim oAcc As Access.Application

On Error GoTo FehlerMeldung

Const TMP = "C:\Test\PWDDaten.mdb"

Set db = DBEngine.CreateDatabase(TMP, dbLangGeneral)
db.NewPassword "", "secure"
db.Close
Set db = Nothing

Set oAcc = New Access.Application
Set db = oAcc.DBEngine.OpenDatabase(TMP, False, False, ";pwd=secure")
oAcc.OpenCurrentDatabase TMP
db.Close
Set db = Nothing

FehlerMeldung:
MsgBox "Anmeldung fehlgeschlagen ", 16, "FEHLER !"

End Function

Thanks in advance
Stefan
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.