Open password-protected access database from vba in runtime mode

S

sugata

Here is my code to open password-protected database, and to open it in
runtime, but they still in to deferent code-step, could anyone help how to
combine the procces opening the password and run the database in runtime
msaccess mode.
I am user Office Xp Developer.
Thank you .

Private Sub cmdOpenPassword(Cancel As Integer)
'Open Password-Protected access database
'Define as Static so the instance of Access
'doesn't close when the procedure ends.
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\CICCOM\RAP\CC2002.mdb"
Set acc = New Access.Application
acc.Visible = False
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=cic")
acc.OpenCurrentDatabase strDbName
acc.Visible = True
db.Close
Set db = Nothing
'Exit application after the database running in another instance
DoCmd.RunCommand acCmdExit
End Sub

Private Sub cmdAccess_Click()
On Error GoTo Err_cmdAccess_Click

Dim stAppName As String

stAppName = "msaccess.exe c:\ciccom\rap\cc2002.mdb /runtime"
Call Shell(stAppName, 1)

Exit_cmdAccess_Click:
Exit Sub

Err_cmdAccess_Click:
MsgBox Err.Description
Resume Exit_cmdAccess_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top