Solved

Can I get the code used in the command line method?

Posted on 2014-09-06
1
136 Views
Last Modified: 2014-09-08
I had this question after watching MS Access – Different Ways to Start Up a Database.
0
Comment
Question by:Wayne Markel
1 Comment
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40307541
The Command Line is run like this:

"full path to msaccess.exe" /x YourMacroName

If you want to use the /cmd switch:

Dim sCmd as String
sCmd = Command

The variable "sCmd" will contain whatever you pass in as the /cmd "argument", so if I did this:

"full path to msaccess.exe" /cmd Arg1|Arg2|Arg3

My "sCmd" variable would contain the value "Arg1|Arg2|Arg3". If I wanted to parse those out, I could do it like this:

Msgbox "First Argument: " & Split(sCmd, "|")(0)
Msgbox "Second Argument: " & Split(sCmd, "|")(1)
Msgbox "Third Argument: " & Split(sCmd, "|")(2)

I could then take actions for each, depending on what you want to do. For example, if I always want to run a Report named "rptDownloads" when I pass in the argument of "DL" in the first postion, I'd issue a command like this:

"full path to msaccess.exe" /cmd "DL|0"

Now my startup form in Access would parse that, and take action:

Dim sCmd As String
sCmd = Command
If Split(sCmd, "|")(0) = "DL" Then
  DoCmd.OpenReport "rptDownload"
End If

See this MSDN Article for more information on all command-line switches:
http://office.microsoft.com/en-us/access-help/command-line-switches-for-access-HA010166605.aspx
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question