locCommand = "My Command"
Main Topics
Browse All TopicsRunning Access XP (2002) / Jet SP 8 on Win XP.
I have a shortcut:
PathToAccess PathToDB /cmd "test"
In my startup form's code, I have:
If Command = "test" Then
.... do something interesting
End If
This doesn't work.
If I do:
MsgBox Command
I get a MsgBox with:
0
Here's the wacky thing:
If I go to Tools > Options > Advanced and look at the field 'command line options' I see my option "test" in the textbox. Opening the database directly shows no option in that box. So, the command switch is doing the right thing. Almost.
Any idea how to get my command line option passed in correctly so that Command() will do what it's supposed to? Or any other way to access a command line?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Okay, I'll try to answer these in order:
-----
phileoca suggested:
dim locCommand as string
locCommand = Command
msgbox locCommand
Result:
0
-----
eghtebas suggested:
locCommand = "My Command"
Dunno what I'm supposed to do with this one. I want to take the Command() value and test it, so I can't set it to a specific value.
-----
heer2351 suggested:
msgbox command()
Result:
0
-----
TextReport suugested:
> Try checking for Command = """test""" or remove the " around Test in your Command Line
Neither of these evaluated to True.
Also:
> PS I normally use Command$ rather than Command.
If I try:
MsgBox Command$
I get:
Compile error:
Type-declaration character does not match declared data type
-----
Thanks for all the suggestions. Here's what I'm trying to do. I'm open to any suggestions solving this problem, either by getting Command() to work or through some other method.
I have a switchboard form. I want two (or more) shortcuts that will open the same .mdb file, yet the switchboard will open to a specific set of menu items. If I have /cmd "reports" I get the report menu, while if I use /cmd "data" I get the data menu. Each menu has an ID associated, so I was using a test like this:
If Command = "reports" Then
switchID = 1
Else ....
and so on.
So, any other ways to use multiple shortcuts to set a variable's value would do the trick for me. I've gotten Command() to work before, but that was in Access 2000.
Thanks for the help!
-- Wes
What is your full Target for your link one that I use for Access 2000 is
"C:\Program Files\Microsoft Office 2000\Office\MSACCESS.EXE" "C:\Documents and Settings\Andrew Jackson\My Documents\MyDatabase.mdb" /WRKGRP "C:\Documents and Settings\Andrew Jackson\My Documents\MKC\MySecurity.m
and this works fine.
Another option to try is the /x macroname that will run the macro called macroname for you.
Cheers, Andrew
The is the shortcut I'm using:
"C:\Program Files\Microsoft Office\Office10\MSACCESS.E
I thought about the macroname, but haven't tried it yet.
I can guarantee my command-line is being run. From the original statement of the problem:
> If I go to Tools > Options > Advanced and look at the field
> 'command line options' I see my option "test" in the textbox.
> Opening the database directly shows no option in that box.
> So, the command switch is doing the right thing. Almost.
Opening the database two different ways puts different values into that textbox on the Advanced tab, so I know my value is being read from the command-line...
The only thing I can think of are
Compact and Repair the Database
Check the VBA References ensure they are all OK and remove ones you don't need.
Try a new database to test for consistency that you can always get the Command working
If the new database is consistent then try and import your existing database until it either works or fails.
Cheers, Andrew
Aha.
First, I inheirited this database from the original designer, who used the switchboard wizard to make his menus. That wizard creates a table with a field named [Command], so my reference was to that.
By qualifying the function with the class name, I was able to force VBA to use the function, not the variable:
If Interaction.Command = "test" Then
....
Thanks.
-- Wes
Business Accounts
Answer for Membership
by: phileocaPosted on 2004-06-23 at 14:52:24ID: 11383830
dim locCommand as string
locCommand = Command
msgbox locCommand