Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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