| |
It
takes the following arguments:
- strDbPath
= full path to the secured database
- strUser
= name of the user account to open the database
- strPassword
= password of strUser
- strWkgrpPath
= full path to the workgroup information file that contains
strUser account
Function GetSecureDb(strDbPath As String, _
strUser As String, _
strPassword As String, _
strWrkgrpPath As String) As Boolean
Dim acApp As Access.Application
Dim strCommand As String
Const APP_PATH As String = "c:\program files\microsoft
office\office\msaccess.exe"
' Build Access command line to pass to Shell function.
strCommand = """" & APP_PATH
& """" & " " &
"""" & strDbPath & """"
_
& " /User" & strUser & "
/Pwd " & strPassword _
& "/NoStartup" & " /Wrkgrp "
& strWrkgrpPath
' Pass command line to Shell function. If this succeeds,
pass
' the database path to the GetObject function and loop
until
' the acApp object variable is initialized.
If Shell(strCommand) Then
Do
On Error Resume Next
Set acApp = GetObject(strDbPath)
DoEvents
Loop Until Err.Number = 0
End If
' Sample command to open an Access form named "Categories".
acApp.DoCmd.OpenForm "Categories"
GetSecureDb = True
' Quit and destroy object variable.
acApp.Quit
Set acApp = Nothing
End Function
|
|