Command() Function to get command line parameter not working

M

Mike B in VT

I'm trying to use the Command function to pass a paramter into Access and it
isn't working. If the parameter is "auto" I want to call a macro to print a
bunch of reports, otherwise I want to display a form.

The Icon is setup as "S:\admin\excel queries.mdb" /cmd "auto"

I have in the only module, and have the AutoExec Macro call it:

Public Function CheckCommandLine()

' Check the value returned by Command function and display
' the appropriate form.

MsgBox Command() ' for debug purposes

If Command = "auto" Then
DoCmd.RunMacro "mcrPrintReports1"
Else
DoCmd.OpenForm "Form1"
End If

End Function

But the msgbox shows up empty and it always just runs the form.
Help!
 
S

Stefan Hoffmann

hi Mike,
The Icon is setup as "S:\admin\excel queries.mdb" /cmd "auto"
You need to specify the Access executable, cause otherwise the shell
handler, which is not aware of command options, is invoked:

"C:\Path\MSACCESS.EXE" "C:\Path\.MDB" /cmd "auto"


mfG
--> stefan <--
 
A

Allen Browne

Include the path to msaccess.exe in the shortcut, e.g.:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"S:\admin\excel queries.mdb" /cmd auto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top