[beginner] opening a base throught vba
-
hi all, i'm using vba under access. i wanna a database secured by a password from another database i used this function in the autoexec macro code: Function Ouvre() Dim ds As DAO.Database Set ds = DBEngine.OpenDatabase("C:\Step3.mdb", False, False, "pwd =alpha") End Function the prob that when i try to open the base it sounds that i couldn't do it. so someone know? how can i wrote a code to connect to the base with password? thx:confused:
-
hi all, i'm using vba under access. i wanna a database secured by a password from another database i used this function in the autoexec macro code: Function Ouvre() Dim ds As DAO.Database Set ds = DBEngine.OpenDatabase("C:\Step3.mdb", False, False, "pwd =alpha") End Function the prob that when i try to open the base it sounds that i couldn't do it. so someone know? how can i wrote a code to connect to the base with password? thx:confused:
You cannot have two separate databases open in the same instance of Access. You can have linked tables from another DB or you can use the 'Shell' command to open the DB in another instance of Access: Private Sub CommandButton_Click() 'Open another database Dim PathNameOfDB As string PathNameOfDB="C:\Pathname\BDName.mdb" Shell "C:\Program Files\Microsoft Office\Office11\msaccess.exe " & "PathNameOfDB", vbMaximizedFocus Application.Quit ' closes current application so new DB is current. End Sub MDBMakers.com is a great source for Access and VBA solutions. Steve -- modified at 8:46 Friday 4th August, 2006