Question : Access 2010: Can I start an ACCDE in runtime mode and supply it's password?

I need to create a shortcut or bat file or vba code or something that starts an encrypted Access 2010 ACCDE  and

o Ensures that it runs in runtime mode even if the retail version of Access is running on the same machine
o Passes it's password to it so that the user does not need to enter a password

I know how to do either or, but not both.  See snippets in code below.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
This in a .bat file will start it in runtime mode:
start "" "C:\Program Files\Microsoft Office\Office14\msaccess.exe" /runtime  "C:\Users\...\MyDB.accde" 

This in vba will pass a password:
' Make the encrypted DB the current DB.
    appAccess.Visible = True
    appAccess.UserControl = True 
    appAccess.OpenCurrentDatabase "C:\Users\...\MyDB.accde", False, "MyPwd"
    
This vba will test for not in runtime mode and stop the DB from running:
 If SysCmd(acSysCmdRuntime) = True Then
        MsgBox "Using Runtime...this is OK"
    Else
        MsgBox "This application must be run with the /runtime switch on"
    End If

Answer : Access 2010: Can I start an ACCDE in runtime mode and supply it's password?

This is a funny problem. You can automate a normal Access session, and you can open an application in runtime mode... Why not automate the runtime application once it's open?

You can start by opening, in runtime mode, a dummy empty database. Then grab the automation handle to that application, and change the current database to your protected application. The code below was tested in Access 2003, so it might not work in your version. It's the entire module of the single startup form of a (third) database; you can do something better in a compiled language (to protect the password).

(°v°)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Private Sub Form_Load()

    Dim strCmd As String
    Dim accRT As Access.Application

    strCmd = """" & SysCmd(acSysCmdAccessDir) & "MSACCESS.exe"" /runtime" _
        & " d:\test\dummy.mdb"
    Shell strCmd, vbNormalFocus
    Set accRT = GetObject("d:\test\dummy.mdb")
    accRT.CloseCurrentDatabase
    accRT.OpenCurrentDatabase "D:\test\protected.mdb", , "zorglub"
    Application.Quit

End Sub
Random Solutions  
 
programming4us programming4us