Solved

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

Posted on 2014-09-06
1
139 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

707 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