Solved

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

Posted on 2014-09-06
1
134 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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now