Data Management

Spotlight Question: Command line code not recognized in Access

TechRepublic member william.beissel frequently uses a snippet of code to open .adp projects in MS2007, but it won't open a .accdb file. Please post your explanation and/or solution in the discussion thread.
TechRepublic member william.beissel submitted the following question.

I am trying to open a .accdb database using the following commands:

myshell = "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" & " " & myFile

myAppID = Shell(myshell, 3)

myFile is a valid path and .accdb file name.

When I execute the commands, I get the following error: "The command line

you used to start Microsoft Access contains an option that Access does not recognize..."

I use this same code to open .adp projects in MS2007 all day long. Why won't it open a .accdb file too? Thanks for any help you can provide.

Please post your explanation and/or solution in the discussion thread. If you can successfully help this member, we will send you a TechRepublic coffee mug.

About

Sonja Thompson has worked for TechRepublic since October of 1999. She is currently a Senior Editor and the host of the Smartphones and Tablets blogs.

4 comments
cactus
cactus

Try with: myshell = Chr(34) & "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" & Chr(34) & " " & Chr(34) & myFile & Chr(34) or just: myshell = Chr(34) & myFile & Chr(34)

Sonja Thompson
Sonja Thompson

TechRepublic member william.beissel frequently uses a snippet of code to open .adp projects in MS2007, but that same code won't open a .accdb file. Please post your explanation and/or solution in the discussion thread. If you're able to help William, we'll send you a TechRepublic coffee mug.

Sonja Thompson
Sonja Thompson

William's problem was quickly resolved. I wish they all were that easy! Cactus, please send your mailing address to trol at techrepublic.com so that I can send a TR coffee mug your way.

william.beissel
william.beissel

Thanks for the response, Cactus. I tried your code but it still did not open the database. However, when I executed this line of code immediately following the myshell = ... myAppID = Shell(myshell,3) then it worked. Looks like myShell = ... alone does not do it.