Open Database with hyperlink. Close the current one

M

mark909

Ive got a form set up in a database with a label hyperlinked to open up
another database when clicked.

Is it possible to make it so that the current database closes when the new
one opens
 
W

Wayne-I-M

Private Sub ButtonName_Click()
Call Shell(Path to other database, 1)
DoCmd.Quit
End Sub

eg

Private Sub ButtonName_Click()
Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE""
""C:\MyDocuments\MyDatabase..mdb", 1)
DoCmd.Quit
End Sub
 
D

Dirk Goldgar

mark909 said:
Ive got a form set up in a database with a label hyperlinked to open up
another database when clicked.

Is it possible to make it so that the current database closes when the new
one opens


You can't do this with a hyperlink. You could have an autoexec macro (or
startup code) in the newly opened database automatically locate and close
the application window that had the previous database open.

Or (better, to my way of thinking) you could use code like this in the first
database to open the new database and close the current one:

'----- start of example code -----
Private Sub cmdSwapDB_Click()

Dim strNewDatabase As String

strNewDatabase = "C:\Users\Mark\Documents\NewDB.mdb"

Shell "msaccess.exe " & Chr(34) & strNewDatabase & Chr(34),
vbNormalFocus

DoCmd.Quit acQuitSaveNone

End Sub
'----- end of example code -----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top