Fix Microsoft Access Ignoring Command-Line Arguments When Another Database is Open
Question details
The user needs to resolve an issue where Microsoft Access fails to receive command-line arguments (the Command$ value is blank) when another database is already running.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Opening a database using a shortcut with a command-line argument while a different Microsoft Access database is already active.
- Observed behavior
- The new Access instance opens, but the command-line argument is ignored and the Command$ value returns blank.
Verify the exact file path to your Microsoft Access executable (MSACCESS.EXE), as this location varies depending on your installed Windows and Office versions.
Specify the Full Path to the Access Executable in the Shortcut
Explicitly defining the path to MSACCESS.EXE in your shortcut forces Windows to start the intended Access instance and pass the command-line parameters correctly, bypassing default file association issues.
When you rely purely on file associations (e.g., targeting the .accdb or .mdb file directly in the shortcut), Windows may attempt to use Dynamic Data Exchange (DDE) to communicate with the already open instance of Access. This can result in the command-line arguments being dropped.
To bypass this, you must construct the shortcut target to point directly to the MSACCESS.EXE application file, followed by the database file, and finally the command-line argument.
Right-click on the database shortcut that is failing to pass the argument and select 'Properties' from the context menu.
Navigate to the 'Shortcut' tab. In the 'Target' field, locate the current path (which likely just points to your database file).
Add the full path to the Access executable in quotation marks at the very beginning of the Target field. For example: "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE".
Add a space after the executable path, then enclose your database path in quotation marks, followed by your command switch. The final target should look like this: "C:\Path\To\MSACCESS.EXE" "C:\Path\To\Database.accdb" /cmd "YourArgument".
Click 'Apply' and then 'OK' to save your new shortcut configuration. Double-click the shortcut to verify that the argument is now passed successfully even if another database is open.

Try WPS Office for Your Document, Spreadsheet, and Presentation Needs
While WPS Office does not include a database management tool like MS Access, it is a fantastic, lightweight, and free alternative for Microsoft Word, Excel, and PowerPoint. Experience high compatibility and a familiar interface without the hefty subscription fees.
- 1. Download WPS Office: Visit the official WPS website and click 'Download WPS Office Free' to get the installer.
- 2. Install the Software: Run the downloaded installer and follow the on-screen prompts to complete the lightweight installation process.
- 3. Open Your Documents: Launch WPS Office and seamlessly open your existing Word, Excel, or PowerPoint files with complete formatting retention.

Frequently Asked Questions
Why does Access drop my command-line arguments when using just the file association?
When you rely on Windows file associations (targeting the database file directly), Windows may use Dynamic Data Exchange (DDE) to send instructions to the existing instance of Access. During this DDE communication, custom command-line arguments passed via the /cmd switch are often ignored or passed as a blank value.
How do I retrieve the command-line argument within Microsoft Access using VBA?
You can retrieve the argument passed via the /cmd switch by using the Command or Command$ function within your VBA modules, forms, or macros. For example, assigning `Dim strArgs As String; strArgs = Command()` will capture the string passed from the shortcut.
Does this issue affect all versions of Microsoft Access?
Yes, this behavior is a longstanding architectural quirk across multiple versions of Microsoft Access. It happens when relying on default file associations while another instance is running. Specifying the executable path directly is the universally recommended workaround.




