0

hopefully there is anybody who can solve my problem. I would start an access db using a link (with /x macro or /cmd para) at the desktop. All is fine if access isn't running but if access is open (working at two database projects) neither /x macro nor /cmd para will work.

I've tried also /runtime with /x and /cmd but no change against the above.

autoexec macro will work fine

so many thanks in advance ralph

braX
  • 11,506
  • 5
  • 20
  • 33
  • similar queston: https://stackoverflow.com/questions/43176599/opening-microsoft-access-with-parameters – jazb Jan 31 '19 at 07:20
  • thanks, this is what I've done but this only works when msaccess isn't running before starting it with parameters – user10994258 Jan 31 '19 at 07:28
  • might be a limitation of access... – jazb Jan 31 '19 at 07:31
  • it seems so I've tested it and if msaccess is running before Command() returns an empty String starting it at first Command() replys the correct string. – user10994258 Jan 31 '19 at 08:06
  • What is your full command-line? It works fine for me in Access 2010 with `path\to\MSACCESS.EXE path\to\myDb.mde /cmd foobar`, no matter how many Access instances are already running. – Andre Jan 31 '19 at 09:48
  • C:\Users\name\Documents\Database2.accdb /cmd Test2 – user10994258 Jan 31 '19 at 14:28
  • many many thanx to Andre - problem solved mistake was link - there must be also path to msaccess.exe – user10994258 Jan 31 '19 at 14:40
  • If the answer solved your problem, you can [accept it](http://stackoverflow.com/help/someone-answers), this also marks the question as resolved. – Andre Feb 01 '19 at 09:28

2 Answers2

0

To make this work, the link (command line) must include the path to msaccess.exe, e.g.

"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" D:\Work\myDb.accdb /cmd foo

It probably is sufficient to use

MSACCESS.EXE D:\Work\myDb.accdb /cmd foo

because MSACCESS.EXE is registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Andre
  • 26,751
  • 7
  • 36
  • 80
0

I just encountered this problem too, and I found that apart from including the path to msaccess.exe there is also another way to make it work.

That is to change the file extension of the access file you open with command line parameters from .accdb to .accdr (which is a way to simulate access runtime). If you do that then the command line parameters will be read properly even if there is already another access file open.

(You must of course change the extension both on the real file and the referring text inside the batch file.)

Magnus
  • 1,584
  • 19
  • 14