Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000 - Command() 2

Status
Not open for further replies.

ginoitalo

Programmer
Feb 15, 2003
23
CA
I'm starting an Access project with a shortcut like so:
C:\InputParams.mdb /cmd frmBlue

When I execute this line I get a blank message box:
msgbox Command$

What's going on ?
 
You are not using the /CMD parameter correctly. When used in a shortcut command line the value that follows the /CMD can be called up by using the Command() function. Just entering it will not open the form. Also, the name of the form since it is a string should be surrounded with double-quotes:
Code:
C:\InputParams.mdb /cmd "frmBlue"

Now in your database copy and paste this code into a database module:
Code:
Function Open_CommandLineForm()
DoCmd.OpenForm Command()
End Function

Now Create a New macro and name it AutoExec. Select RunCode from the Action drop down box and enter in the Function box Open_CommandLineForm().

You database will now open and open the form [blue]frmBlue[/blue]

Post back if you have more questions.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Hi,

Command() is virtually the same as Command$()

When trying:
C:\InputParams.mdb /cmd "frmBlue"

nothing shows up when I execute:
msgbox Command$

ie. the quotes did nothing

p.s.
obviously I don't expect the form to open with a msgbox prompt, the issue is that the string "frmBlue" should be in the messagebox and it isn't.
 
You have to launch msaccess.exe from your shorcut in order to get the /cmd stuff with the Command function, like this:
"C:\Program Files\Microsoft Office\OFFICE[highlight]?[/highlight]\MSACCESS.EXE" C:\InputParams.mdb /cmd frmBlue

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV: Good catch there. Yes, the command line has to be expanded to first include the complete path to the MSACCESS.EXE file. It is always best to use double-quotes around this path string as well as the path to the database to be opened. Double-quotes around the form name to be opened are not necessary unless the name has spaces included in it, which is a very bad idea in naming database objects.

The rest of what I posted above works with this update to the command line.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
I've got it working now, thanks to the posters.

The database takes an extra 20 seconds to show the message box containing the result of Command()

This operation is really expensive !
the database is virtually empty, it only has 1 macro to call the only function the shows the msgbox, no tables either.

that's no good ! is this fixable ?
 
I have created a dup of what you are doing and mine opens in 2-3 seconds. Try performing a compact and repair of your database and try again.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
The results are odd,

after pressing the compact and repair the database restarts and the msgbox pops up right away, but when I try the shortcut (most of the time) it takes 20 seconds to popup, in that time nothing in the database can be clicked, it's busy.

...strange

if it helps any,
Access 2000 on Win2k Pro SP4
 
Why don't you post your command line string. Let's see it here and see if we can see something strange.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 

Shortcut Used:
"C:\Microsoft Office\Office\MSACCESS.EXE" "C:\Work\InputParams.mdb" /cmd frmBlue

autoexec macro --> runcode --> fncStartup()

modStartMe
-------------
Public Function fncStartup()
MsgBox Command()
End Function


That's everything
 
Only that I see here that may be nothing at all is: Usually the Microsoft products are installed in the C:\Program Files\Microsoft Office\Office directory. Your path string does not include Program Files. If it should then add it in. If it should then maybe the system is having a difficult time finding the msaccess.exe with a bath path to start with. Taking a little longer to get there.

I am grasping at straws here. Don't see anything else. I have an identical setup that is taking 1-2 seconds to bring up the message box.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
The path to MSAccess.exe is correct for my system, I didn't use the default install path.

It's a mystery.
 
Pkg up in a new dataabase just those items you mentioned. Try running it then with just those items. If no difference then send it to my email adress(see profile) and let me run it here. It sounds like it is the msaccess.exe.

I say that because when you already have your msaccess opened and do the compact and repair there is no loading of the application software, just the .mdb and execution of the code. That works fine. But, when you start at the shortcut level you are requiring the loading of MS ACCESS first and then the .mdb file. This is where the slow opening occurs I believe.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
I received your db and the command line string. I got the same error as you did. Seems the /CMD is not understood by A2K. Had to change it to a semi-colon to get it to work. The semi-color is a substitute for the /CMD. Works as advertised now.

Good luck with your project.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Works like a charm

therefore, /cmd != ;

Many thanks to scriverb for his time and effort.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top