Open Database with hyperlink. Close the current one

  • Thread starter Thread starter mark909
  • Start date Start date
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
 
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
 
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 -----
 
Back
Top