Command-Line Switches
Microsoft Access is usually run from the Start menu or by double-clicking on an Access database file. What is not usually done is to run Access using the command line (DOS window). However, if Access is started using the DOS window, there are some command-line switches available to modify the behavior of the program during startup.
Command-Line Switches
The following table shows the available command-line switches for Microsoft Access:
| Switch | Purpose |
| /excl | Opens the database file in exclusive mode. |
| /ro | Opens the database file in read-only mode. |
| /user username | Opens the database file using the supplied username |
| /pwd password | Opens the database file using the password supplied |
| /profile userprofile | Opens the database file using the options in the user profile instead of the default settings. |
| /compact filepath | Compacts and repairs the database file to a different file. If filepath is not used, the original database file is compacted. |
| /convert filepath | Converts the database file to an upgraded version. |
| /x macroname | Executes the specified macro at startup. |
| /cmd | Used to pass an argumet that can be retrieved using the Command() function in Access. |
| /nostartup | Starts Access without displaying the startup dialog box. |
| /wrkgrp filepath | Starts Access using the supplied .mdw security file. |
| /runtime | Starts Access in RunTime mode. |
Examples
- To open a database file in exclusive mode
- C:\FullPathTo\MSACCESS.EXE C:\FullPathTo\Database.mdb /excl
- To open a database file in read-only mode
- C:\FullPathTo\MSACCESS.EXE C:\FullPathTo\Database.mdb /ro
- To open a database file and execute a macro called "startup"
- C:\FullPathTo\MSACCESS.EXE C:\FullPathTo\Database.mdb /x startup
- Note: To have a macro run each time the database is opened, name it "autoexec."
- To open a secured database using a workgroup file called "mysecurity.mdw"
- C:\FullPathTo\MSACCESS.EXE C:\FullPathTo\Database.mdb /wrkgrp C:\FullPathTo\mysecurity.mdw
- C:\FullPathTo\MSACCESS.EXE C:\FullPathTo\Database.mdb /runtime
Note: If any part of the path or the filename contains spaces, you should enclose it with double quotes.