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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening another instance of Access from Access 1

Status
Not open for further replies.

Robotron

Programmer
Mar 16, 2004
72
US
I am attempting to build a database that I can track other databases I am creating and maintaining. What I am trying to do is open any given database in a new instance of Access from my application.

I have tried OpenCurrentDatabase and OpenDatabase. These seem only to apply if you are working from a non Access application.

Is there a way to open in a new window another database?

Phil Edwards
 
Have you tried using the Shell command to invoke another instance of MSAccess.exe, sending over the name of the mdb as one of the parameters.

You might also consider using the ShellExecute API, which would only required that you pass the name of the mdb.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks. Using the Shell function, I get the following error:

invalid procedure call or argument

Here is the code I am using:

Dim strPath As String
Dim RetVal As Double

strPath = Me.Location
RetVal = Shell(strPath, 1)

I appreciate your help.

Phil Edwards
 
If you read my post carefully, you must invoke MSAccess.exe with the name of the mdb as a parameter. The Shell function only works with executable files (.exe, .bat, .com, etc)

If you only want to use the .mdb file, then you must use the ShellExecute API which will invoke the proper executable based on the established file associations.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
BTW, what is Me.Location?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
My apologies. I had misread your first post. I now have it working. Thanks for the help.

Me.Location is VBA code for the current form and the value of the "Location" text box on the current form.

Phil Edwards
 
To help out, he is a sample using the ShellExecute API. First declare the API in the declarations section, then make the call inside of some procedure.
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'===========================================

Private Sub Form_Load()
   
   ShellExecute 0, "open", "<full pathname to then .mdb file>", vbNullString, vbNullString, 0

End Sub
The API call does not have to be in the Form_Load event, that is just where I put it for this example.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top