?
Solved

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

Posted on 2014-09-06
1
Medium Priority
?
140 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

762 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