[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


call shell function in ms access not going to currentproject path

Posted on 2014-07-17
Medium Priority
Last Modified: 2014-07-19
this code is not changing directory to the current project path. my access database is in several directories and I need to reference the current path.

the following code works fine, but not the flexible to current directory

Call Shell("cmd.exe /k cd\priworkfile\temp\zfws-6-1-14-mastergtest && wxfws.py", vbNormalFocus)

this code does not cd to the currentdirectory

Private Sub Command7_Click()

    Dim NewName As String
    Dim OldName As String
    OldName = CurrentProject.Path
    NewName = Right(OldName, Len(OldName) - 2)

    MsgBox (NewName)
    'Dim Shell As String
    Call Shell("cmd.exe /k cd (NewName)" & """wxfws.py""", vbNormalFocus)
End Sub

would appreciate the correct setting to change to the current directory.
Question by:JimMello
  • 2
LVL 58
ID: 40202881
<<would appreciate the correct setting to change to the current directory. >>

 You don't do a CD in the Shell() command, but rather specify the full path directly, or a relative path (using ..)

 If you want to change directories specifically, then you need to script out a batch file with the CD command in it and whatever else, then call the batch file with Shell()

LVL 25

Expert Comment

ID: 40203483
You have a typo in your command. Try this one:
Call Shell("cmd.exe /k cd " & NewName & "wxfws.py", vbNormalFocus)

Open in new window


Author Comment

ID: 40205839
this does not work, error message, "the system cannot find the path specified."
LVL 25

Accepted Solution

chaau earned 1500 total points
ID: 40205905
If you have spaces in the path name you need to enclose it in quotes, like this
Call Shell("cmd.exe /k cd """ & NewName & "wxfws.py""", vbNormalFocus)

Open in new window


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question