Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing current database and opening another?

Status
Not open for further replies.

ZappaDog

Technical User
May 13, 2002
25
US
I am trying to write a function which will close the currently active database and open another one. I can get another database open, but can't seem to close the original one.
 
I have "snipped" a portion of a complete module I use to open up another session of Access and close the currebnt section (under certain circumstances).

You could try this if you like.

I also ensure that if the current session is running under "runtime" version that the "new" session is also opened up in "runtime". Again you may have to play with it a bit.

' ------------------------------------


Dim Path2AccessEXE As String
Dim RunText as String
Dim Result As Variant

Path2AccessEXE = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"

'Get workgroup and login information
WrkGrpLogin = "/wrkgrp """ & SysCmd(acSysCmdGetWorkgroupFile) & """ /user " & glb_CurrentUser

RunText = &quot;&quot;&quot;&quot; & Path2AccessEXE & &quot;&quot;&quot; &quot;&quot;&quot; & <YourDatabaseToOpen>

If SysCmd(acSysCmdRuntime) Then
RunText = RunText & &quot; /runtime&quot;
End If

' Give the &quot;Shell&quot; command a window to operate

'Open a new instance of Access and pass it the command line variable.
Result = Shell(RunText, vbNormalFocus)

'Then close this instance of Access
Application.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top