Run Data Base Application

R

Roger Bell

I have a command button to run another data base from within the current data
base as follows: "On Click Event Procedure" I get A 'File not found' error

Private Sub PRESBYTERY_ACCOUNT_Click()
On Error GoTo Err_PRESBYTERY_ACCOUNT_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE\
D:\My.Mdb"

Call Shell(stAppName, 1)

Exit_PRESBYTERY_ACCOUNT_Click:
Exit Sub

Err_PRESBYTERY_ACCOUNT_Click:
MsgBox Err.Description
Resume Exit_PRESBYTERY_ACCOUNT_Click

End Sub

Thanks for any help
 
D

Damian S

Hi Roger,

Assuming that your path to Access is correct, the problem is the extra
backslash after MSACCESS.EXE... it should look like this:

"C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE D:\My.Mdb"

Hope this helps.

Damian.
 
R

Roger Bell

Thanks for your help Damian. If the Data Base file is located on a different
drive as this the case here and in a Folder of that drive, it does not seem
to work. Does that indicate that the DB file must always be in the Root
Directory of the nominated drive?
Thanks again
 
J

John W. Vinson

Thanks for your help Damian. If the Data Base file is located on a different
drive as this the case here and in a Folder of that drive, it does not seem
to work. Does that indicate that the DB file must always be in the Root
Directory of the nominated drive?

No, certainly not!!! Performance is sometimes degraded if you have a huge long
string of subdirectories but it still works.

My guess is that you have a blank somewhere in the path - D:\My Documents\...
or the like. If your path contains even one blank, then you MUST enclose the
entire path and filename in quotes.

In addition, the path to the MSACCESS.EXE executable is the first operand; the
path to your database is a second operand and should be in its own quotes.
E.g.

"C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE" "D:\Some
Path\My.Mdb"

Also, since you're apparently opening Access *from within Access*, consider
whether you really need two Access sessions open simultaneously! You can use
File...Get External Data...Link to link to tables, or even the OpenDatabase
method to gain access to forms or reports. Why two databases, and just what
are you trying to accomplish!?

John W. Vinson [MVP] <Elder in Boise Presbytery>
 
R

Roger Bell

Thanks John
This is the code & still not working:
Private Sub Command143_Click()
On Error GoTo Err_Command143_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office11\MsAccess.Exe"
"D:\Parish DataBases\Finances\presbyteryaccount.mdb"
Call Shell(stAppName, 1)

Exit_Command143_Click:
Exit Sub

Err_Command143_Click:
MsgBox Err.Description
Resume Exit_Command143_Click

End Sub
 
J

John W. Vinson

Thanks John
This is the code & still not working:
Private Sub Command143_Click()
On Error GoTo Err_Command143_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office11\MsAccess.Exe"
"D:\Parish DataBases\Finances\presbyteryaccount.mdb"
Call Shell(stAppName, 1)

Exit_Command143_Click:
Exit Sub

Err_Command143_Click:
MsgBox Err.Description
Resume Exit_Command143_Click

End Sub

Well, I rarely use Shell and never for opening a database from another
database.

Again: WHY!?

Just what are you trying to *accomplish* here?

One more thing to try: quotes within quotes! See if

stAppName = """C:\Program Files\Microsoft Office\Office11\MsAccess.Exe""
""D:\Parish DataBases\Finances\presbyteryaccount.mdb"""

works as expected. This will pass

"C:\Program Files\Microsoft Office\Office11\MsAccess.Exe"
"D:\Parish DataBases\Finances\presbyteryaccount.mdb"

with the quotes included as an argument.

John W. Vinson [MVP]
 

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