Open a database in current instance.

  • Thread starter Thread starter Jason Lee
  • Start date Start date
J

Jason Lee

Hi,

I have several databases in one application. I need to
switch between them. All the database are useing the same
workgroup file.
I want to open the other database within the current Access
instance, so user does not need to log in again. How can I
do it?

Thank you
Jason Lee
 
Jason,

Either link the tables in the other databases, or if you want to do it in
code, see Help for the "OpenCurrentDatabase" or "OpenDatabase" methods.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
hi,

I am really stock here.

I have several databases. What I want to do is when I click
on a button on a form in database-1, it closes the current
database, and open database-2, exactly like clicking the
menu file -> open.

I tried to open an other instance of access for the new
database, but the databases are secured, every time a new
password was required for the new databse. I want to avoid
the login, and use the current user name and password.

Is there any better way to do it?
Thank you for your information.

Jason
 
Jason,

I haven't tried it, but I'm pretty sure you can't do exactly what you want,
the reason being that the code to open the second database is still running
in the first database while you're opening the second. Even after it
actually opens the second database, it would still need to "execute" the End
Sub line, and so would keep the first database open.

Having said that, it might be worth setting DBEngine.SystemDB = the path of
the workgroup file, and supplying your username and password in the
OpenCurrentDatabase/OpenDatabase methods.

Another thing you might like to investigate is supplying username and
password in a desktop shortcut.
1. Create a shortcut to the database in question.
2. Open the shortcut, and add the following to the Target field (watch
for newsreader line wrap - it should all be on the same line):

"path to msaccess.exe" "path to database.mdb" /wrkgrp "path to
workgroup file.mdw" /user yourusername /pwd yourpassword

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Paul,
Thank you for your information.
I tried the TSI SOON addin you suggested. However, there is
a problem I could not solve. When open my first database in
an exsiting access instance using file -> open then the
path, the program works perfectly. When I open the first
database from shot cut or from explorer, the first switch
was good, but the second switch or the third switch will
close the access instance. To me, it looks like if the
database I am switching to is in the current path which was
showed from file -> open menu, it works fine, otherwise, it
shot the instance down. Since it is .dll file, I can not
realy figuer out what is going on.

My code as following: When the form was opened, it switch
to the other database.

Private Sub Form_Open(Cancel As Integer)
Dim MyDBDir As String
'The OpenArgs save a string of the full path of the
'destination database file.
MyDBDir = Forms![Switch].OpenArgs
With COMAddIns("TsiSoon90.Connect").Object
.FileToOpen = MyDBDir
.Exclusive = False
.FileIsAdp = False
.CloseAll

end sub

Jason Lee
 
Back
Top