Open another database .accdr (1 Viewer)

JPaulo

Developer
Local time
Today, 06:07
Joined
Dec 21, 2009
Messages
185
Hi all;

vba code, accdb how to open another database .accdr with password ?
 

JPaulo

Developer
Local time
Today, 06:07
Joined
Dec 21, 2009
Messages
185
This cod does not work to open .accdr

Sub OpenDB()
Dim MinhaPassword As Variant
MinhaPassword = "xpto"
strDbName = "c:\SeuBanco.accdr"
Set objaccess = New Access.Application
Set db = objaccess.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & MinhaPassword)
objaccess.OpenCurrentDatabase filepath:=strDbName
End Sub
 

JPaulo

Developer
Local time
Today, 06:07
Joined
Dec 21, 2009
Messages
185
Can anyone help?
 

vbaInet

AWF VIP
Local time
Today, 06:07
Joined
Jan 22, 2010
Messages
26,374
This cod does not work to open .accdr

Sub OpenDB()
Dim MinhaPassword As Variant
MinhaPassword = "xpto"
strDbName = "c:\SeuBanco.accdr"
Set objaccess = New Access.Application
Set db = objaccess.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & MinhaPassword)
objaccess.OpenCurrentDatabase filepath:=strDbName
End Sub

I've not recently done this but here's a suggestion. There's one line that looks like vb.net code or visual basic code. Replace your code with this:

Code:
Sub OpenDB()
Dim MinhaPassword As String, strDbName as string
Dim objAccess as Access.Application

MinhaPassword = "xpto"
strDbName = "c:\SeuBanco.accdr"
Set db = objAccess.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & MinhaPassword)
objAccess.OpenCurrentDatabase filepath:=strDbName
End Sub

See if this works, don't quote me on this.
 

JPaulo

Developer
Local time
Today, 06:07
Joined
Dec 21, 2009
Messages
185
Thanks for responding, but still does not work.
Note that want to open mode runtime (accdr).
 

JPaulo

Developer
Local time
Today, 06:07
Joined
Dec 21, 2009
Messages
185
So it does not work.

Function OpenACCRD()
With New Access.Application
.OpenCurrentDatabase "c:\teste.accdr", , "MyPassword"
.UserControl = True
.RunCommand acCmdAppMaximize
End With
Application.Quit
End Function

Help me please.
 

vbaInet

AWF VIP
Local time
Today, 06:07
Joined
Jan 22, 2010
Messages
26,374
So it does not work.

Function OpenACCRD()
With New Access.Application
.OpenCurrentDatabase "c:\teste.accdr", , "MyPassword"
.UserControl = True
.RunCommand acCmdAppMaximize
End With
Application.Quit
End Function

Help me please.

I didn't even pick up on the accdr file format. Have a look at these links in order of relevance:

http://support.microsoft.com/kb/235422
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_22871426.html
http://support.microsoft.com/kb/105128
 

Users who are viewing this thread

Top Bottom