Connecting to another access database. (1 Viewer)

peters

Registered User.
Local time
Today, 08:08
Joined
Nov 9, 2000
Messages
24
I have set-up a nice, using forms and command buttons, a nice menu for my database.

I have attempted to added to this menu a command button that would allow me to close the current database and open another access database.

I tried a few things with macros and such but obviously didn't succeed.

Can this be done? Would I have to do this through a macro?

Thanks, Peter.
 

ElsVanMiert

Registered User.
Local time
Today, 08:08
Joined
Dec 14, 2000
Messages
152
You can not solve this problem with a macro. Have a look at the ACCESS ONLINE ENCYCLOPEDIA at www.unsoftwareag.com (general issues).
Here is the code to solve your problem (also copied from the Encyclopedia):
How can I open another application and close the current app?
Sometimes it can be necesary to leave the current application and to open another one. You could use this technique to access archive or training data especially if it is not possible to simply re-link the backend tables to another database.

One solution seems to be using the SENDKEYS commands, but this fails often in a multilanguage environment.

The following solution is much more efficient:
Use the "SHELL" method to open the "other" application.
Close the current application with "application.QUIT".

Code:

Dim strAppName = "c:\ACCESSPath\MSACCESS.exe c:\MDBPath\MDBName.mDB"
Call shell (strAppName,1)
Application.quit

Attention:
If you have activated the security system then you need to use the command line options:
/wrkGrp for the MDW file
/user for the username (you might use the CurrentUser in the beforementioned code)
/pw for the password

Furthermore you could use /cmd for any macro
Close all open objects:
Object.close
Set Object=nothing
Before you quit the current application.
You can open any other program with the same code.
 

Users who are viewing this thread

Top Bottom