Check directory for Access

G

Guest

Hello. I need to change the following to first check where the Access
application is depending on if it is 2000 or 2003. The 2003 would be in
C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE, so I would need a
DIR command I believe to see if the folder exists. My code is the following:

Private Sub Monthend_Loan_Database_Click()
Shell """C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"" " & _
"""\\Hr\COMMON\DATABASE\Monthend Loan Reports.mdb""", _
vbNormalNoFocus
End Sub

I am not getting it to work trying to fit in for 2003. Any help
appreciated. Thanks!
 
6

'69 Camaro

Hi, Mike.
to first check where the Access
application is depending on if it is 2000 or 2003.

One can always rely on the following to determine the path where the
MSAccess.exe file is located, regardless of what version of Access is being
used:

SysCmd(acSysCmdAccessDir)

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
G

Guest

OK, now I have the code as:

Private Sub Monthend_Loan_Database_Click()
Dim strAccessDir As String
strAccessDir = SysCmd(acSysCmdAccessDir)
Shell strAccessDir & _
"""\\Hr\COMMON\DATABASE\Monthend Loan Reports.mdb""", _
vbNormalNoFocus
End Sub

But when I execute this I get a Run Time Error'53', File Not Found. What
should I correct in this?
 
6

'69 Camaro

Hi, Mike.
But when I execute this I get a Run Time Error'53', File Not Found. What
should I correct in this?

When you concatenate the string containing the path and file name with
another string containing a path and file name, don't forget to concatenate
a space between these two strings, so that the operating system can tell
that it's a command and a command line argument being passed to it, not just
a single command to execute.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
G

Guest

Got it working now!

Here are two of the routines:

Private Sub Balances_Database_Click()
Dim strAccessDir As String
strAccessDir = SysCmd(acSysCmdAccessDir)
Shell strAccessDir & "MSACCESS.EXE" & " " & _
"""N:\Balances.mdb"" " & _
"/wrkgrp " & """N:\BASE.MDW""", vbNormalFocus
End Sub

and

Private Sub Monthend_Database_Click()
Dim strAccessDir As String
strAccessDir = SysCmd(acSysCmdAccessDir)
Shell strAccessDir & "MSACCESS.EXE" & " " & _
"""N:\Reports.mdb""", vbNormalFocus
End Sub

Thanks!
 

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