Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Command Line > < Track Changes | Export PDF >
Command Line Parameters
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   6 years ago

Access Command Line Parameters, Switches, Arguments


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Join Now

Chris from the United Kingdom (an Access Developer Member) asks, "Is it possible to pass a user-defined parameter via the command line when opening Access?"

Members

I'll show you what to do once you get the parameter in your database. You can open different forms, hide buttons on your Main Menu, and more.

Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!

Links

Microsoft Command Line Switches: https://tinyurl.com/y3eax2vc
Microsoft Command Function https://tinyurl.com/y65x4vrv

Learn More

FREE Access Beginner Level 1
FREE Access Quick Start in 30 Minutes
Access Level 2 for just $1

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates

Resources

Diamond Sponsors - Information on our Sponsors
Mailing List - Get emails when new videos released
Consulting - Need help with your database
Tip Jar - Your tips are graciously accepted
Merch Store - Get your swag here!

Questions?

Please feel free to post your questions or comments below or post them in the Forums.

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Command Line Parameters
Get notifications when this page is updated
 
Intro In this video, I will show you how to pass command-line parameters when opening a Microsoft Access database. You will learn how to use Windows shortcuts to send custom arguments to Access, how to read those parameters using the Command function in VBA, and some practical examples for customizing your database startup based on these parameters. This can help you set up different modes, manage user-specific options, or add simple security features to your Access applications.
Transcript Welcome to another TechHelp video brought to you by AccessLearningZone.com. I am your instructor, Richard Rost.

In today's video, I am going to show you how to open Access with a parameter - how to pass command-line arguments when opening Microsoft Access. Today's question comes from Chris in the UK, one of my Access Developer members.

Chris asks, is it possible to pass a user-defined parameter via the command line when opening Access? Yes, Chris, it is definitely possible, and you can use this technique to open Access in different modes depending on what you want to do or even who is accessing it.

Command-line parameters, or arguments or switches, have a lot of different names. They go way back to the DOS days when you used to type in the name of a program and then slash some options. You can do the same thing with Microsoft Access.

The easiest way to do this is to use a shortcut to your database. Here's my actual database file. Let's create a shortcut. Right click and drag, then drop and create a shortcut. Here's a shortcut to my database.

If you are not familiar with Windows shortcuts, you need to take my Windows Basics class. Once you have the shortcut, open up its properties. Right click and come down to Properties. Right here where it says Target, there is the full path and name of my database. After that, put a space, then forward slash CMD. That tells Access the next thing is going to be a command-line parameter. Space, then inside quotes, whatever you want it to be. I will put in here, like, "hi there." You can put whatever you want inside that command-line parameter.

Once you have that, hit Apply, then OK. Now, when I open up the database with that parameter, we have to have a way to read it in here. To read that parameter, we use the command Command. It's actually a function called Command.

My main menu here is my startup form that I specified for the database. Let's go in here. In the On Open event for the startup form, do something real simple. Find the On Open event, select it, and pick your code builder. If you have not taken any of my classes with VBA, you might get a window that asks what builder you want. Always pick the code builder to use VBA.

Then, in here, let's just do something very simple: just say MessageBox, then put the word "Command," and then ampersand Command. That's all that is. We are going to MessageBox the word "Command" followed by Command.

Now, let's close this database down. Save changes, yes. If I open up the regular database without the shortcut, I get just "Command," and it is blank. There is no command-line parameter sent to it.

However, if I open it up with the shortcut, there you go - "Command: hi there." That's how you get a command-line parameter or a switch, whatever you want to call it, into your Access database.

Now that you have it, you can do whatever you want with it. You can use it to control what form opens up. You can control things based on the user. You can put the username in that parameter as simple security.

If you have not gone through all the steps in the Security Seminar that I have to set up actual user security, you could set up a separate shortcut for each of your users with their name in it. As long as they are not Access experts, it is good enough. It will open up their form, put their username in it, and all that stuff.

That is how you send a command-line parameter to Microsoft Access.

For the members, there is a members-only extended cut edition of this. I will show you how to do stuff with that parameter. First, we will deal with a problem that sometimes comes up when you use a parameter - it sometimes sends extra spaces in there and you have to be careful to watch for that. I will show you how to use the parameter to control what form opens when the database starts. You can open up a different form based on what user is opening the database.

I will also show you how to hide buttons on the main menu so that if an admin opens it up, you can see everything. If it is not an admin, if it is a normal user, you can hide the accounting buttons or whatever based on that parameter switch.

How do you become a member? Just click on that Join button down below the video. You will get access to all of my extended cut TechHelp videos. If you are still remembering up, you can see a list of all the different types of memberships that are available on the following menu. But do not worry, my TechHelp videos will still be free. I will keep making them as long as you keep watching them.

Make sure you give me a like and share this video if you think any of your friends or colleagues will benefit from it. Make sure you subscribe to my channel and click the bell. That way, you will get notifications by email anytime I release a new video.

Subscribing is absolutely free. Make sure you click the Show More button down below the video in the description. YouTube does a pretty good job of hiding it, but there are lots more extra resources down there.

If you have not yet checked out my Access Level 1 class, it is free. It is three hours long. Check it out. It is on YouTube and my website. It is all the basics of Microsoft Access: forms, queries, reports, table design, all that stuff.

If you like Level 1, Level 2 is just one dollar, and that is also free for members.

If you want to see your questions answered in a video just like this one, visit my TechHelp page. Also, stop by my website and check out the Access Forum. There is my other cool stuff: Facebook, Twitter.

For me, Richard Rost, and everyone else here at AccessLearningZone.com, thank you for watching. I hope you learned something and we will see you next time.
Quiz Q1. What is the main topic of this TechHelp video?
A. How to pass command-line parameters when opening Microsoft Access
B. How to secure a database using user accounts
C. How to design reports in Microsoft Access
D. How to import data from Excel into Access

Q2. What is the function of the /cmd switch in an Access shortcut?
A. It opens the database in read-only mode
B. It indicates that a command-line parameter will follow
C. It sets the default printer
D. It minimizes Access on startup

Q3. In the example from the video, where is the command-line parameter entered?
A. In the database options menu
B. In the table design view
C. In the Target field of the shortcut properties
D. Inside an Access macro

Q4. To read the command-line parameter inside Access, which function is used?
A. GetParameter
B. Command
C. ParamInput
D. Argument

Q5. What does displaying "MessageBox 'Command' & Command" accomplish in the startup form?
A. Shows a welcome message regardless of the parameter
B. Prompts for a new password
C. Displays the passed command-line parameter, if any
D. Changes the form title

Q6. What happens if you open the database normally (not using the special shortcut)?
A. Access crashes
B. The command-line parameter is blank
C. The parameter displays "default"
D. The form does not load

Q7. What is a potential use for passing a username as a parameter to Access?
A. Changing the database language
B. Printing reports automatically
C. Simple user-based security or interface customization
D. Disabling database features

Q8. Why might you want to use different shortcuts with different parameters for different users?
A. To update Access automatically
B. To open different forms or hide/show specific buttons based on user
C. To run database repairs
D. To backup the database

Q9. When should you choose the code builder in the On Open event?
A. When writing VBA code to respond to the event
B. When creating a new table
C. When designing a report
D. When running a saved query

Q10. What issue with command-line parameters was mentioned as covered in the extended cut for members?
A. Access ignoring parameters completely
B. Parameters being truncated at random
C. Extra spaces sometimes being included in the parameter
D. Parameters being visible to all users

Answers: 1-A; 2-B; 3-C; 4-B; 5-C; 6-B; 7-C; 8-B; 9-A; 10-C

DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary Today's video from Access Learning Zone covers how to start Microsoft Access with a parameter by passing command-line arguments. This technique is useful if you want your database to behave differently depending on how it is launched or who is accessing it. The question for today comes from Chris in the UK, who wanted to know if it is possible to pass a user-defined parameter via the command line when opening Access. The answer is yes, and I will explain how to do it.

Command-line parameters are also called arguments or switches. They have been around since the DOS era when you would run a program and add special options after its name. Microsoft Access still supports this feature. To use command-line parameters with your Access database, the most straightforward way is to create a Windows shortcut to your database file.

Find your Access database file and create a shortcut to it. Once the shortcut is created, open its properties. In the Target field, you will see the path to your database. After the path, add a space, then type forward slash CMD and then another space. After that, add your parameter inside quotation marks. For example, you might want to pass "hi there" as your parameter, but you can put whatever you need.

After saving the changes to the shortcut properties, you can now open the database through this shortcut. The key part is reading this parameter from within your Access application. To do that, you use the Command function in VBA. If you want to work with this parameter as soon as the database opens, you can place code in the On Open event of your startup form.

In the event code, a simple way to see the parameter is to show a message box that displays the output from the Command function. When you open the database normally, without using the shortcut, the value will be blank because no parameter was passed. When you open it through the shortcut, you will see the message box show your command-line parameter, like "hi there."

Once you have access to this parameter, you can use it in various ways. For instance, you could control which form loads at startup, adjust what is visible based on who is logging in, or pass in a username as a form of basic security. While this method is not a replacement for full user security (like you might find in my Security Seminar), it works for simple situations, especially if your users are not Access experts. Each user can get a shortcut with their name as the parameter, and you can programmatically control the experience based on that input.

For those of you who are members, there is an extended cut of this video. In the extended cut, I will show you more advanced techniques using the command-line parameter, such as dealing with extra spaces that sometimes appear, using the parameter to determine which form opens at startup, and dynamically hiding or showing buttons on the main menu based on the user's role. For example, admin users can see all options, while regular users have some choices hidden, all determined from the parameter.

If you would like to become a member, there are several membership levels available. Becoming a member gives you access to all my extended cut TechHelp videos. However, regular TechHelp videos remain free and I will continue creating them for anyone who wants to learn.

If you found this information useful, please share it with others, subscribe to my channel, and consider clicking the bell for notifications when I post new content. Subscribing is completely free, and there are many resources and links available in the video description, though YouTube likes to hide the "Show More" button.

If you are new to Access, my free Access Level 1 class covers all the basics and is available both on YouTube and on my website. Level 2 is just one dollar and is also free for members.

If you have a question you would like to see answered in a future video, visit my TechHelp page. Also, consider joining my Access Forum or connecting with me on Facebook or Twitter.

You can find a complete video tutorial with step-by-step instructions on everything discussed here on my website at the link below. Live long and prosper, my friends.
Topic List Creating a shortcut to open an Access database
Adding command-line parameters to an Access shortcut
Using the /cmd switch to specify command-line arguments
Accessing command-line parameters in VBA with the Command function
Displaying the passed parameter with a message box in Access
Configuring the On Open event of a startup form to read parameters
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 1/23/2026 6:05:18 AM. PLT: 2s
Keywords: TechHelp Access Opening Microsoft Access with Command Line Parameters, Switches, Arguments - Command Function  PermaLink  Command Line Parameters in Microsoft Access