Question OpenCurrent **SECURE** Database

xBug

Registered User.
Local time
Today, 02:27
Joined
Apr 30, 2009
Messages
11
Hi, is there way to get Pointer to NEW Access-secure-instance, without prompting for user pasword FROM ACCESS ?
Code:
If ll_RUN_SHELL Then
    lc_AC_EXE = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"
    lc_USER = CurrentUser
    lc_PWD = "password"
    lc_DB_SEC_CMD = " /NOSTARTUP /USER " & lc_USER & " /PWD " & lc_PWD
    lc_DB_SHELL = lc_AC_EXE & " " & filePath & lc_DB_SEC_CMD
    ln_RC = Shell(lc_DB_SHELL, vbNormalFocus)
    If SHELL_STARTED(CLng(ln_RC)) Then
        Set oRetApp = GetObject(, "Access.Application")
[COLOR=red]' Returns pointer to First/CurrentDatabase, not to Second/Shell_DB...!!![/COLOR]
' Need for :    oRetApp.Run "XX_MAIN"
        If Not (oRetApp Is Nothing) Then
            ll_Ret = True
            WW_SET_ForeGWIN oRetApp.hWndAccessApp
        End If
    End If
Else
    '[COLOR=red] if Secure, *** Prompts *** User for Password...[/COLOR]
    ' bStrPassword = DB-password (Not User password)
   [COLOR=red]' MISSING  --–>  optional bStrUserPassword as String :mad:[/COLOR]
    oRetApp.OpenCurrentDatabase filePath, Exclusive
End If
 
Last edited:
For the OpenCurrentDatabase method, you can try this approach:
Code:
[COLOR="Navy"]Dim[/COLOR] rs [COLOR="navy"]As Object

Set[/COLOR] rs = oRetApp.DBEngine(0).OpenDatabase(filePath, , , _
    "OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Password=[B][I]MyUserPassword[/I][/B];" _
    & "User ID=[B][I]MyUserName[/I][/B];" _
    & "Jet OLEDB:System database=[B][I]C:\MyFolder\MySystemFile.mdw[/I][/B]")

oRetApp.OpenCurrentDatabase filePath, Exclusive

[COLOR="DarkGreen"]' Insert your processing code here[/COLOR]

oRetApp.CloseCurrentDatabase

rs.Close
[COLOR="navy"]Set[/COLOR] rs = [COLOR="navy"]Nothing[/COLOR]
 

Users who are viewing this thread

Back
Top Bottom