ACC: How to Use Command-Line Switches in Microsoft Access

This article was previously published under Q105128
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
When you run Microsoft Access from the Start menu or a shortcut, (orProgram Manager or File Manager in Microsoft Windows 3.x), you can usecommand-line switches to modify the startup process. For example, you canopen a particular database, run a macro, or supply a password.
Microsoft Access recognizes the following command-line switches:

In version 1.x only:
   /s                  Bypasses the Microsoft startup screen.				
NOTE: The startup, or splash screen, in Microsoft Access can also besuppressed using the Microsoft Access version 1.x Distribution Kit (ADK).

In version 2.0, the /s switch no longer applies. Instead, include the StartupScreen entry to display your own bitmap logo rather than thedefault Microsoft Access logo. Although this is a setting for ADTapplications, this entry can also be used without the ADT. Include thefollowing statement in your MSACC20.INI file:
   [Run-Time Options]   StartupScreen=C:\LOGO\MYBITMAP.BMP				
In version 2.0 only:
 /Ini <initialization file>    Starts Microsoft Access using the options in                               the specified initialization file instead of                               the standard MSACC20.INI file. The                               initialization file must have the same                               entries as the standard MSACC20.INI file.				
In Microsoft Access 1.x, 2.0, 7.0, and 97:
   <database>          Opens the specified database.   /Excl               Opens the database for exclusive access.   /Ro                 Opens the database for read-only access.   /User <user name>   Starts Access using the specified user name.                       You'll be prompted for the path to Msaccess.exe.   /Pwd <password>     Starts Access using the specified password.                       You'll be prompted for the path to Msaccess.exe.   /X <macro>          Starts Access and runs specified macro.   /Cmd                Specifies what value to pass to the Command                       function in an Access Basic procedure that is                       called by a RunCode action in an AutoExec macro.                       This option must be the last option on the command                       line.				
In Microsoft Access 2.0, 7.0, and 97:
 /Compact <target database>    Compacts the database specified before the                               /Compact option and then closes Microsoft                               Access. To compact to a different name,                               specify a target database. /Repair                       Repairs the specified database and then                               closes Microsoft Access. /Convert <target database>    Converts a version 1.x database to a                               version 2.0 database,                               with a new name, and then closes Microsoft                               Access. Specify the source database before                               the /Convert option.				
In Microsoft Access 7.0 and 97:
 /Profile <user profile>       This replaces the /ini option used in                               previous versions to specify an                               initialization file. The option starts                               Microsoft Access using the options                               in a specified user profile instead of                               the standard Windows Registry settings. /NoStartup                    This option starts Microsoft Access without                               displaying the startup dialog box. /Wrkgrp <system filename>     You can start Microsoft Access with a                               specific workgroup. /Runtime                      Starts Microsoft Access in run-time mode.				
NOTE: To use the /Runtime switch with Microsoft Access 97, you must install the Microsoft Office 97 Developer Edition Tools (ODE) or acustom application created with the ODE on your computer.
 /Convert <target database>    Converts a database in an earlier version                               (1.x or 2.0) to a Microsoft Access 95 or                               97 database with a new name, and then                               closes Microsoft Access. Specify the                               source database before the /Convert                               option.				
For example, you could type the following command in the Run dialog box (available by choosing Run from the Program Manager File menu):
   c:\access\msaccess.exe Northwind.mdb (or NWIND.MDB in versions 1.x and   2.0) /Excl /X Add Products				
This sample syntax starts Microsoft Access, opens the Northwind (or NWINDin versions 1.x and 2.0) sample database for exclusive use, and runsthe Add Products macro. Note that you must include the file name,Msaccess.exe, as shown in the example.

In Microsoft Access 97:
/unregserver   Forces Microsoft Access to unregister itself and then               exit./regserver     Forces Microsoft Access to register itself.				
Because Microsoft Access is a self registering program, you can use the/unregserver and /regserver switches to remove or refresh the Access registry entries. This can be useful when you need to make sure all Access files are properly registered, but you can not use the "Setup /y" option of the Access setup program. For more information about using "Setup /y", see the following article in the Knowledge Base.
148424 ACC: Troubleshooting Invalid Page Faults in MS Access 95 and 97

Recommended Order of Command-Line Switches

The following is the order to follow when creating command-line switches for Access database shortcuts. All switches are optional.

Document conventions:
<> - Place holder for required text.
<<>> - Place holder for optional text.
{} - Supplies additional information about switch, but should not be copied into command-line.
/wrkgrp <system filename>
/User "<username>"
/Pwd "<password>"
/Profile <user profile> <database>
/Compact <<new database>> {Do not use with repair switch}
/X <macro> {Not the recommended method, use "Autoexec" macro instead or startup options. Do not use with compact or repair.}
/Cmd <value> {Must always be last. Do not use with compact or repair.}
For more information about command line switches, search the Help Indexfor "command-line options," or ask the Microsoft Access 97 OfficeAssistant.
start up startup

Article ID: 105128 - Last Review: 12/04/2015 09:45:58 - Revision: 2.2

  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
  • kbnosurvey kbarchive kbhowto kbui KB105128